drewmccormack / ensembles

A synchronization framework for Core Data.
MIT License
1.63k stars 131 forks source link

Saving deletions results in "Deleted object with no global identifier" #148

Closed nikok closed 10 years ago

nikok commented 10 years ago

I noticed this issue in my app and just reproduced it in the Idiomatic Mac app. Please consider this scenario:

The last step throws an exception in the context save: method and also logs "[CDEEventBuilder addDeleteChangesForChangesData:]_block_invoke_2 line 262: Deleted object with no global identifier. This can be due to creating and deleting two separate objects with the same global id in a single save operation....".

I'm guessing that the CDESaveMonitor contextDidSave: method is called and tries to store the deletion of the note a second time. However, it cannot properly register the deletion as the note has already been deleted from the other client.

Any thoughts on this would be greatly appreciated.

drewmccormack commented 10 years ago

Do you mean it crashes the app completely, with an exception, or that you get a warning logged out?

drewmccormack commented 10 years ago

BTW what is the exception thrown by the save?

nikok commented 10 years ago

Yes, the exception is thrown by the save (see screenshot below). It doesn't crash the app and probably doesn't matter that much. I'm getting it when I set a breakpoint on all Objective-C exceptions.

image

drewmccormack commented 10 years ago

I can't seem to reproduce this. I tried with Idiomatic on iOS and on Mac. Create note, sync, delete note on second device, sync, note disappears on first device. No error.

I think something else is probably going on. The exception in save: could have something to do with.

Things to check: 1) Are you properly merging the merge changes into all of your contexts? Use the delegate method provided for this. 2) Is it possible that you are deleting an object and then inserting another object with the same global identifier without an intervening save? That is usually how this warning appears. 3) Are you using the latest master version of the framework? 4) Are you sure this is actually a problem? Does the app crash? Does it sync properly, or are you left with different data on each device?

asciiz commented 10 years ago

I noticed a similar issue in my app:

Client A: create object Client A: sync (no issues)

Client B: sync (no issues)
Client B: delete object Client B: sync (no issues)

Client A: sync (exception)

Logged: __50-[CDEEventBuilder addDeleteChangesForChangesData:]_block_invoke_2 line 262: Deleted object with no global identifier.

Tested on 10.8.5 using Dropbox, single context. The app doesn't crash and synced properly.

drewmccormack commented 10 years ago

I think the log message is harmless, and probably disappears if you lower the log level. It is just a warning, not an error, I think. At least in the most recent versions.

Drew

On 12 Jun 2014, at 17:23, asciiz notifications@github.com wrote:

I noticed a similar issue in my app:

Client A: create object Client A: sync (no issues)

Client B: sync (no issues)

Client B: delete object Client B: sync (no issues)

Client A: sync (exception)

Logged: __50-[CDEEventBuilder addDeleteChangesForChangesData:]_block_invoke_2 line 262: Deleted object with no global identifier.

Tested on 10.8.5 using Dropbox. The app doesn't crash and synced properly.

— Reply to this email directly or view it on GitHub.