What is the best way to know when a replication is finished?

Replications seem to go active, idle, then active again, and sometimes multiple times. This makes it difficult to know when a replication has truly gone idle and is finished working.

What is the best way to determine that a replication is done working? For push replications, we tried checking the GetPendingDocumentIDs (but this is not implemented for download). Also,this method doesn’t always seem to go back down to zero, although I need to test some more to verify.

How is the “IsRunning” property set? Will IsRunning be false when the replication is started but not active (ie, idle and not downloading/uploading)?

Not sure which version of CBL you are on (the activity states are slightly different in 2.0). Have you tried comparing for changesCount with completedChangesCount to see if all pending changes are fetched?

Yes, I’ve had to do a combination of checking the replication statuses and the changes vs completed count since it appears that sometimes the replication is “Idle” when it has changes > 0 and completed == 0.

A continuous replication will go Idle when it’s caught up, i.e. there are no current changes to send or receive. Then it keeps watching and will go Busy again if more changes appear.

A one-shot replication will just go to Stopped when it completes processing all changes.

sometimes the replication is “Idle” when it has changes > 0 and completed == 0

That sounds like a bug with tracking change counts. What version/platform are you using? (In any case, I would trust the .active property more than the counts.)

We are using 1.4 of CBLite .NET. Here is a log statement I printed from earlier today:

2017-08-21 09:37:47,834 [12780] DEBUG: Replication changed event received for Puller 197d7ad8-97ab-4b77-8400-5db5240b8b63. Current Status: [Idle], Previous Status: [Idle], Is Running: [True], Changes Count: [1], Completed Count: [0], Last Error: []

Looks like a bug …Tagging @borrrden

Even when changes are > 0 , status is Idle. How to get exact replication Idle?. (using active_task REST api to get following data)
"completed_change_count": 13708,
“source”: “server_url”
“task”: “syncGwPuller”,
"status": “Idle”,
“progress”: 98,
“continuous”: true,
“target”: “ptxdata”,
"change_count": 13908,
“type”: “Replication”

The thread above is for tracking replications initiated from Couchbase Lite. It appears that you are using Sync Gateway replications (with SG Replicate ?). If so, please start a separate post on the same along with details of version of Couchbase Mobile etc