Watch out for Cloudant replication errors

I have been able to use Cloudant NoSQL databases for free (within $50 limit) since early 2015. Checking the usage every month or so seemed sufficient. What a surprise when I saw $467 usage in one of the environments in the middle of this month!

The first thing I checked was when the usage started to grow. I saw a spike starting on 14 October last month:


Then I checked my other environments and the same date marked a spike of GET requests in the production environment:


I have no continuous replications set up, but this clearly showed that some replication is going on. The type of the requests (GET from the production system and GET/POST/PUT in the backup system) also pointed to a replication issue.

My usual replications are set to run once a week, the continuous excessive usage ruled them out. I was now looking for any obvious signs, but no database seemed to contain any excessive number of records, and it does not help that there is no information in Cloudant about which database the hits relate to.

I checked all replication records, verified that none was running, and that none was set up wrongly. One useful information is the _rev (revision) number in the replicator that tells you how many times the given replication ran:





..means these replication ran 27 times, each about every month.

Nothing unusual, I was puzzled. What happened on 14 October? I made a list of all activities I did, collected details of applications that are using the database, no luck.

Then I checked active replications again and to my surprise I found a ghost replication running against one of the databases. And in a few minutes another!

I quickly checked the replicator database and now the replications showed up:



773,460 replication runs??? There was the culprit. This is about one replication per hour since 14 October.

I canceled both replications and they did not come up since. But where did they come from? They were not visible inside the replicator database before and I can’t see any reason why they would be created a month ago.

Watch out for Cloudant errors. No system is perfect.