We recently updated our cluster to Couchbase 3.0.1 Community and are facing a problem we never had to deal with with previous versions. Indeed, from time to time, with the latest Couchbase version, view are “corrupted” and include multiple occurrences of a key that was emited only once.
We tried and reproduced the bug with a simple script that populates a bucket with 1.000.000 documents containing a single field “random” which is assigned a random value in the 0-9 range. Then you just have to perform random updates by requesting all object with a given “random” value using the following view :
function (doc, meta) {
emit(doc.random, null);
}
You just have to update the “random” field to a new random value, save the documents and after a while you’ll notice duplicates in the index, a document is emitted more than once and we don’t understand why.
Do you have any ideas concerning the origin of our problem?
Note that it is entirely valid for the map function to call emit() multiple times, so if your function does that you can end up with more than one entry in the view results. That’ll depend on your view logic.
If you’re confident that your view logic doesn’t do this, can you check the map_reduce.errors log to see if there is something “interesting” in there? Also, if your map function is small-- could you post it here? If it’s really complicated, it may be better to post it elsewhere (like a gist on github) and post a link here.
My bad, I have run a lot of different tests and this may not be representative of what really happens. I’m going to clear logs and run the tests again. I’ll link the new logs as possible.