Let's say you PUT the following document into _replicator:
{ "_id": "my_rep", "source": "http://myserver.com:5984/foo", "target": "bar", "create_target": true }
In the couch log you'll see 2 entries like these:
[Thu, 17 Feb 2011 19:43:59 GMT] [info] [<0.291.0>] Document `my_rep` triggered replication `c0ebe9256695ff083347cbf95f93e280+create_target` [Thu, 17 Feb 2011 19:44:37 GMT] [info] [<0.124.0>] Replication `c0ebe9256695ff083347cbf95f93e280+create_target` finished (triggered by document `my_rep`)
As soon as the replication is triggered, the document will be updated by CouchDB with 3 new fields:
{ "_id": "my_rep", "source": "http://myserver.com:5984/foo", "target": "bar", "create_target": true, "_replication_id": "c0ebe9256695ff083347cbf95f93e280", "_replication_state": "triggered", "_replication_state_time": 1297974122 }
Special fields set by the replicator start with the prefix
_replication_
.
_replication_id
The ID internally assigned to the replication. This is also
the ID exposed by /_active_tasks
.
_replication_state
The current state of the replication.
_replication_state_time
A Unix timestamp (number of seconds since 1 Jan 1970) that
tells us when the current replication state (marked in
_replication_state
) was set.
When the replication finishes, it will update the
_replication_state
field (and
_replication_state_time
) with the value
completed
, so the document will look like:
{ "_id": "my_rep", "source": "http://myserver.com:5984/foo", "target": "bar", "create_target": true, "_replication_id": "c0ebe9256695ff083347cbf95f93e280", "_replication_state": "completed", "_replication_state_time": 1297974122 }
When an error happens during replication, the
_replication_state
field is set to
error
(and
_replication_state
gets updated of course).
When you PUT/POST a document to the
_replicator
database, CouchDB will attempt to
start the replication up to 10 times (configurable under
[replicator]
, parameter
max_replication_retry_count
). If it fails on
the first attempt, it waits 5 seconds before doing a second
attempt. If the second attempt fails, it waits 10 seconds before
doing a third attempt. If the third attempt fails, it waits 20
seconds before doing a fourth attempt (each attempt doubles the
previous wait period). When an attempt fails, the Couch log will
show you something like:
[error] [<0.149.0>] Error starting replication `67c1bb92010e7abe35d7d629635f18b6+create_target` (document `my_rep_2`): {db_not_found,<<"could not open http://myserver:5986/foo/">>
The _replication_state
field is only set to
error
when all the attempts were
unsuccessful.
There are only 3 possible values for the
_replication_state
field:
triggered
, completed
and
error
. Continuous replications never get
their state set to completed
.