Conflict warnings


Using CBL 1.4, SyncGate 2.1.2 and CBS 6.0.0.

Having warnings in clients logs like (where ADDR is my database url and ID is document id number):

RemoteRequest: com.couchbase.lite.replicator.RemoteRequest {PUT, http://ADDR/db/_local/ID}: Got error status: 409 for http://ADDR/db/_local/ID. Reason: Conflict

And info from server logs looks like:
[INF] HTTP: #965: PUT /db/_local/ID
[INF] HTTP: #965: --> 409 Document update conflict (1.5 ms)

Everything on both sides seems to work as expected.
Is it just internal talk with client and gate/server or not?


Its’ basically normal. It just means a document was updated on both client and server, and then the client tried to sync. The client will pull the conflicting revision from the server and then resolve the conflict.

@jens, thanks!

I forgot to mention that doc ID is always the same for each client. I assume this has to be a SyncGate doc for syncing purposes?

Oh wait — I just looked at the URLs more closely. This is a conflict saving replicator checkpoints. That shouldn’t happen. Can you describe the replications that are running on the clients, i.e. push or pull and what options?

Also if you are copying a database from one device to another, let us know the process. A simple file copy to another device will cause this issue.

Hmm, what exactly should I check on?
I am using Java and both push and pull continuous replications like so:

        // Get manager object.
        Manager mManager = new Manager(new AndroidContext(context), Manager.DEFAULT_OPTIONS);

        // Attach database.
        mDatabase = mManager.getDatabase(Schema.Database);

        // Create replication filter.
        mDatabase.setFilter(Schema.Filters.Main, new ReplicationFilter() {


        // Add database change listener.
        mDatabase.addChangeListener(new Database.ChangeListener() {


        // Create pull replication.
        pull = mDatabase.createPullReplication(url);
        pull.setAuthenticator(new PasswordAuthorizer(name, password));

        // Create push replication.
        push = mDatabase.createPushReplication(url);
        push.setAuthenticator(new PasswordAuthorizer(name, password));


        // Start replication.

Inside ChangeListener I check for documents conflicts and handle them.

I dont, but my app lets user to decide whether he likes to store documents online and share them, so technically at 1st run a new database with default name is created/opened(?). When user creates account then I query all his documents and add some attrs so they can be replicated to SyncGate and to other users. Then I start replication like in post above. I see 2 possible scenarios here if you are talking about database “copying”:

  1. A new user who might have some docs. But in this case he has a new database which never has been synced with server.
  2. An old user who re/installed app and logged into his account. In this case he has some replication history on server. But user devices may vary.

Might this be a root of the problem?

By copying I mean physically copying a database from one device to another (even for the same user). It doesn’t sound like you are doing anything like that though (some people do it to preseed, but that is the wrong method for doing so).

On Android 6 and up there is an autobackup feature for users. System copy all data(all specified data in app manifest). So technicaly there is copying at least on the same device if user uninstall and then install app.

It won’t make a difference on the same device, but if the user were to put the backup onto another device and continue using both then this situation could easily happen.

OK, I will double check my testers in that particular situation.