CBL2.0 How should I ensure replication is finished and the documents in CBL is the same as the Server side

we are using CBL 2.0 db22 with SG 2.0, I have some questions about state (cbl 2.0 is changed so mach from previous).
the documents says

[STOPPED] means The replication is finished or hit a fatal error.
[IDLE] means The replication caught up with all the changes available from the server. The IDLE state is only used in continuous replications.

so 1) how should I ensure replication is finished and the documents in CBL is the same as the Server side?
A) should I check the state is [STOPPED] and there is no error?
Or B) should I check the state is [IDLE] only?
and 2) how should I ensure the documents in CBL is the same as the Server side?
the documents says

You can access the Sync Gateway _all_docs endpoint http://localhost:4984/db/_all_docs?include_docs=true to check that the documents are successfully replicated.

I think it is not right way to do this job on application side, because it is not high performance.
3) is there any high performance and easy way to check the documents in CBL is the same as the Server side?

Stopped and Idle work just like in 1.x. When a one-shot replication finishes, it goes to Stopped state. When a continuous replication finishes (for now), it goes to Idle. So you should check for either state, and no errors.

I think it is not right way to do this job on application side, because it is not high performance.

You’re right; I don’t know why that’s in the docs. I filed a ticket; you can do the same using the Feedback button at the bottom-right of the docs page.

Thank you very much.
so for bi- directional replication, I should check the state goes to Idle with no errors in continuous replication, that means replication is finished and the documents in CBL is the same as the Server side. and I should not check SG _all_docs endpoint in application. Am I right?

Continuous is a bit tricky because since it is designed to run forever, it is never “done.” You cannot rely on idle to be completely sure that it has received all documents because it sometimes goes idle for a few moments temporarily before resuming again. The best way to know is to run a one-shot replication, which will stop once it catches up with the changes it receives at the time it started.

1 Like