2
votes

I am working on implementation of a progress bar to display replication progress between a remote CouchDB database and a local browser-hosted PouchDB database.

Currently, I am using the number of documents in each of these databases to determine the percentage of progress. However, if a large number of records are replaced in either database, then this percentage progress is not accurate.

I would like to use some other value to display replication progress. Can I count on the sequence numbers for two databases that have completed replication to be identical once replication is complete?

2

2 Answers

2
votes

You can use active tasks endpoint for your case. Besides other things it includes a progress percentage for the task. A replication task for example will look like this

{
        "checkpointed_source_seq": 68585,
        "continuous": false,
        "doc_id": null,
        "doc_write_failures": 0,
        "docs_read": 4524,
        "docs_written": 4524,
        "missing_revisions_found": 4524,
        "pid": "<0.1538.5>",
        "progress": 44**,
        "replication_id": "9bc1727d74d49d9e157e260bb8bbd1d5",
        "revisions_checked": 4524,
        "source": "mailbox",
        "source_seq": 154419,
        "started_on": 1376116644,
        "target": "http://mailsrv:5984/mailbox",
        "type": "replication",
        "updated_on": 1376116651
    }

The update seq number is specific to the database. Suppose you have 9 documents in a database and the update_seq for it is 17. update_seq indicates that the database has been updated 17 times even though the number of documents are 9. Now if you replicate it to a new database which is empty then the update_seq of the new database would be 9 because it has only been updated 9 times. Since the new database was empty only 9 new documents were created.

If it contained a few documents then the update number would have been different depending upon what their _rev's were. So update_seq can't be relied upon to calculate progress of replication operation.

1
votes

A trick I often use is to use the last_seq/update_seq as a progress indicator. E.g. see my answer here.