We are encountering an issue where the replicator syncs changes while we are simultaneously writing changes to the same document. Although we are aware of concurrency control options such as lastWriteWins
and failOnConflict
, these do not resolve our problem. Here is the scenario:
- Client A makes changes to Doc1, Doc2, and Doc3.
- Client B’s device replicator initiates.
- Client B runs business logic in the pull filter, identifying the need to make changes to Doc1, Doc2, and Doc3.
- The application updates Doc1, Doc2, and Doc3, and saves the changes.
- The replicator’s pull filter returns true, overwriting the changes made to Doc1, Doc2, and Doc3.
In essence, both the replicator and the application are making changes to the documents concurrently.
One potential solution is to return FALSE for the affected documents in the pull filter, preventing the replicator from pulling changes when certain business logic conditions are met, thereby allowing the application to make custom changes. However, this approach seems fragile and limits the pull functionality.
- Is there a way to specify: First sync, then let the application overwrite ?
I assume this will involve some sort of serial access, but we also don’t want to do long running operations as part of the pull sequence. - Is there a callback where CBLite which emulates:
didWriteToDisk
What is the official recommendation for handling this situation?