Serious bug in view generation
After adding two entries to the database with
set("SQEN3FX4WHOK", {"name":"Stefan","timeMS": 1328186190296,"type": "notification","msg":"{\"id\":25,\"type\":\"newMessage\",\"msg\":\"notification\"}"
})
and
set("1F1U153LL06XA", {"name":"Stefan","timeMS": 1328186190569,"type": "notification","msg":"{\"id\":26,\"type\":\"newMessage\",\"msg\":\"notification\"}"
})
(the quotes are wrong or misssing because I have copied the above together. "msg" is a JSON object represented by a string but that shouldn't matter) within about 300ms (note the timestamp in timsMS) with the Java client and calling the view
function(doc) {
if(doc.type == "notification")
emit(doc.name, doc.msg);
}
with
http://127.0.0.1:8092/default/_design/notifications/_view/mynotifications?key="Stefan"
I get this:
{"total_rows":15,"rows":[
{"id":"SQEN3FX4WHOK","key":"Stefan","value":"{\"id\":25,\"type\":\"newMessage\",\"msg\":\"notification\"}"},
{"id":"SQEN3FX4WHOK","key":"Stefan","value":"{\"id\":26,\"type\":\"newMessage\",\"msg\":\"notification\"}"}
]}
Note that both entries in "rows" have the same "id"!!!
Both entries can be queried correctly with get, it seems that just the index of the view is broken. Adding another item to the database which then is also emitted in the view doesn't fix it. After regenerating the view (by for example adding a space in the view code somewhere) all is fine again and the ids are different.
The bug is very easy to reproduce here.
I am using Couchbase 2.0 preview 3 on Mac OS Lion.
Stefan
Hi Stefan
Thanks for reporting this error. We are working on releasing Developer Preview 4 in a few days with several issues with views resolved and this issue should be fixed as well. I just tested this scenario on a recent build and see the correct behavior.
{"total_rows":10,"rows":[
{"id":"1F1U153LL06XA","key":"Stefan","value":{"id":26,"type":"newMessage","msg":"notification"}},
{"id":"SQEN3FX4WHOK","key":"Stefan","value":{"id":25,"type":"newMessage","msg":"notification"}}
]
}
Screenshot of the UI with view and query results: https://img.skitch.com/20120302-g2tebyigr38if2dnatarn7arc1.jpg
Note that 2.0 DP4 was released this morning, so you should have a fix to this issue now. Please let us know if you still see problems.
Yes, I am seeing the same issue: www.couchbase.com/forums/thread/duplicates-returned-view-results