Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hanging replications on Cloudant

In the last months, we've been charged for a lot of HTTP requests we were not expecting on Cloudant. By looking at CouchDB console locally, I found out that for each continuous replication a GET request is issued every 5 seconds or so.

I have stopped all the continuous replications I could find in Futon and I did the same for every Cloudant accounts we have. By looking at Cloudant's dashboard, I have seen a reduction of GET requests (many thousands), but it did not went down to a reasonable level. So there must be some continuous replications left, but I cannot find them.

How can I find and stop the remaining replications?

like image 363
mll Avatar asked Nov 12 '22 23:11

mll


1 Answers

To identify continuous replications that may be hidden to the user, the best way is to query a curl command, invoke _active_tasks, and apply a jq filter to display only those tasks of type "replication".

That is to say, in the command line, run a command of the following form:

curl 'https://username:[email protected]/databasename/_active_tasks | jq 'map(select(.type == "replication"))'

The same methodology can be applied to retrieve other active tasks (view_compaction, database_compaction, etc.)


That said, in general, Cloudant-based replication is much smoother when using the _replicator database. To do so:

1) As an initial one-time task, create the database:

 https://username.cloudant.com/_replicator 

2) Then, create a document for every replication. If you have "continuous":true in the doc it will be treated as continuous.

3) Then, to cancel the replication you simply delete the document.

All of the above commands (e.g. creating and deleting documents) are well documented on Cloudant's website as well as throughout Stack Overflow, so please refer there for further details.

Finally, it is imperative to add the usr_ctx field so that the replication gets triggered and run within your user context. This is critical so that it shows up when you query _active_tasks, otherwise it'll run anonymously and only show up in the _active_tasks if queried by an admin. This is precisely what happened in the case of the original poster.

like image 186
Jake Epstein Avatar answered Dec 21 '22 09:12

Jake Epstein