How to reset replication

42 views
Skip to first unread message

Todd Freese

unread,
Jan 30, 2016, 11:29:57 PM1/30/16
to Couchbase Mobile
Is there a way to reset replication? For example, I clear the server backing database and I want all clients to resync and push all client docs to the server from scratch.

Searching past posts on this list, there are a couple posts talking about a checkpoint reference on the SG that keeps track of the last replication. But I don't see an api to reset the replication status to start from the beginning.

I know this is an odd request, but I have a unique situation where I want my clients to re-push their docs to the server.

This is all CBL IOS and SG with CB as a backing database.

T

Jens Alfke

unread,
Jan 31, 2016, 12:55:20 AM1/31/16
to mobile-c...@googlegroups.com

On Jan 30, 2016, at 8:29 PM, Todd Freese <to...@filmworkers.com> wrote:

Is there a way to reset replication? For example, I clear the server backing database and I want all clients to resync and push all client docs to the server from scratch.

To do this you’d delete all the client-set checkpoints saved on the server. We don’t have an official way to do it (though it’d be a nice enhancement), but speaking off the record, you can do it with the Couchbase smart-client API by deleting every document in the bucket whose key starts with “_sync:local:”.

—Jens

Todd Freese

unread,
Feb 1, 2016, 1:46:23 PM2/1/16
to Couchbase Mobile
Is there anything I need to do on the clients? If I try to sync with a new sg/cb server, one starting with a new empty database. all the docs from the clients are not getting sent to the server.

T

Todd Freese

unread,
Feb 1, 2016, 1:54:08 PM2/1/16
to Couchbase Mobile
I see in my SG log:

GET /shotbotdb/_changes?feed=normal&heartbeat=30000&style=all_docs&since=1399


Where is the since=1399 coming from? The client or the server? I would think the since value would be 0.


T

Jens Alfke

unread,
Feb 1, 2016, 2:04:30 PM2/1/16
to mobile-c...@googlegroups.com
On Feb 1, 2016, at 10:46 AM, Todd Freese <to...@filmworkers.com> wrote:

Is there anything I need to do on the clients?

You shouldn’t need to do anything. When the replicator starts, it reads its checkpoint from a doc stored on the remote server (ID looks like “_local/“ followed by a hex number.) If it’s not found or if the contents don’t match the local copy of the checkpoint, it decides it’s out of sync [sic] and starts over from scratch.

If I try to sync with a new sg/cb server, one starting with a new empty database. all the docs from the clients are not getting sent to the server.

Hm, that shouldn’t be happening.

I see in my SG log:
GET /shotbotdb/_changes?feed=normal&heartbeat=30000&style=all_docs&since=1399
Where is the since=1399 coming from? The client or the server? I would think the since value would be 0.

1399 is the saved last-sequence value, which is the main thing stored in the checkpoint. If the server database is new, the replicator shouldn’t be sending that. However, the request you’ve shown is part of a pull replication, not a push.

The best thing to do would be to turn on SyncVerbose logging in CBL, then run the replication, and file an issue. (Paste the log output into a gist and put a link in the issue, please.)

—Jens
Reply all
Reply to author
Forward
0 new messages