Faulty `SingleQueryChange` event when merging remote and local object
See original GitHub issueThere is an inconsistency in the notifications reported from https://github.com/realm/realm-kotlin-samples/blob/main/MultiplatformDemoWithSync/shared/src/commonMain/kotlin/io/realm/kotlin/demo/model/CounterRepository.kt#L90
The issue is observed when initializing a new instance of the app when there is already data on the server side. Thus, creating a local Counter
-object with same primary key as already existing on the remote side. When the remote data is synced the emitted events are not as expected and not consistent across platforms:
On Native (iOS/macos) the emitted changes are:
SingleQueryChange: io.realm.kotlin.notifications.internal.InitialObjectImpl@27e15e8
SingleQueryChange.obj: io.realm.kotlin.demo.model.entity.Counter@2dd17d8
Followed by
SingleQueryChange: io.realm.kotlin.notifications.internal.DeletedObjectImpl@2152478
SingleQueryChange.obj: null
Where as on Android the emitted events are:
SingleQueryChange: io.realm.kotlin.notifications.internal.InitialObjectImpl@883a296
SingleQueryChange.obj: io.realm.kotlin.demo.model.entity.Counter@19a1e17
Followed by:
SingleQueryChange: io.realm.kotlin.notifications.internal.InitialObjectImpl@51c7433
SingleQueryChange.obj: io.realm.kotlin.demo.model.entity.Counter@af733f0
Issue Analytics
- State:
- Created a year ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
Git: Merge a Remote branch locally - Stack Overflow
The idea here, is to merge "one of your local branch" (here anotherLocalBranch ) to a remote branch ( origin/aBranch ). For that,...
Read more >How to Merge in Git: Remote and Local Git Repositories Tutorial
Follow this PowerShell Git tutorial on how to merge in Git, meaning how to take a local repository and merge it into a...
Read more >Chapter 29 Pull, but you have local work
If commit C (on the remote) and commit D (local) have changes to the same parts of one or more files, Git may...
Read more >git: fetch and merge, don't pull | Mark's Blog
The other problem is that by both fetching and merging in one command, ... If you want to create a local branch based...
Read more >How to merge master into any branch in GitLab by examples
I can rectify this problem with a GitLab merge master into this branch. When the merge is complete, the release and master branch...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hm, I think that is intentional…i.e. the Notification system is allowed to handle multiple transactions at once and combine their notification. But we probably failed to consider the implications in our implementation of
SingleQueryChange
.I suspect that we might have to fake some of these notifications.
What is concerning though is that @rorbech is seeing a DeletedObject on Native…I don’t have a good explanation for that one … Unless…it is DiscardLocal client reset happening without us noticing it? 🤔
The object deletion events was caused by re-running tests that creates objects with statically assigned primary keys but different partition values. Sync will correctly delete new objects with the same primary key even though the partition value is different because it is backed by a collection that only uses the primary key-field as primary key.
The behaviour in the sample demo app must have been due to old sync history with same situation (same primary key object but different partition key) laying around generating the same deletion events. Disabling and reenabling sync flushed that history and eliminate the issue.