I use 1 server for development and there were nothing in logs (for that time period).
UPD:
After some time error strangly disappeared and it worked well with both doc and manually generated json…
Then I’ve flushed bucket. Added some docs - worked well. Then some more. And finally error appear again. I’ve updated design doc above to current version (on which error is present). Logs are clean.

That’s because you have another view in the same design document using _sum as its reduce function.
All views belonging to the same design document are updated and built simultaneously - querying one view of the design document (without stale=ok) will trigger an update of all views in the same design document.

FilipeManana wrote:
The problem happens only when 2 or more views in the same design document have exactly the same map function and different reduce functions.
That's I'm talking about :). Thanks for help.

PS: I thought that it could be nice, if couchbase developers implement views that can have one map function and many named reduce functions, i.e. create some reduce functions that count items and find unique items. Then via rest api query view with param reduce=_count or reduce=find_unique.

Something strange is in section “input reductions:”. I can’t explain why it has array of 2 identical messages (in base there is only one doc with that id). So in some strange way it duplicates that message in reduce.

Also this error appeared after next manipulations:

Add some docs.

Query view with stale false.

Add some more docs.

Query again and receive error.

So when I create separate new design doc with view that contains identical map/reduce functions error not appear. All works as expected.

If i replace it with another function (i.e. _count) it work well. And if I return this function it throw error again. But strange thing is that if I create separate (new) design doc and view with same map/reduce functions it works well. So reduce function seems to be correct.
UPD: More info.

So as I understand that two views conflict between each other. Map functions of this 2 views are identical, but they have different reduce functions. Maybe index process takes results from first view and tries to apply reduce function of second view.

UPD2: Created another bucket to reproduce with _sum error again. There is no constant doc count after which couchbase view start failing. At first I’ve added about 15 docs and all worked well. But then I’ve some new docs and it failed. I can backup that bucket if it help.
UPD3: Bucket snapshot and logs from lastest test:

Not in that way. I’ve proposed to predefine multiple reduce functions (in query time just select one), i.e. if you need in one app for one map to use _count, _sum, and something else. Now you need to create 2 views with same map and 2 different reduces. What I’ve proposed - the same way as it works now (to pre-compute all defined reduce functions), but on query just to select that I need in this moment.

Added the 2 ddocs, then the first doc, ran both queries: both succeeded, no errors. Then I added the second document, queried both views, and again no errors. Both queries returned exactly the same results.

In your previous logs I saw some weird stuff I can’t explain. It might be worth checking if your machine has good memory, by running a memory test tool such as memtest86+.

Couchbase views (like Apache CouchDB) are materialized views and it means that reductions are pre-computed, with the goal of providing fast querying (just streaming data from disk directly to client without computation).

Therefore adding such a query option ?reduce=whatever would imply at query time to apply the reduce/rereduce function against all emitted key/value pairs, not only this is CPU intensive, but also IO intensive, as it would need to go down to every leaf of the underlying btree to grab the emitted key/value pairs - instead of using the reduce value from the root node (for queries with ?group=false) or reductions from upper levels in the tree (queries with group_level=N or startkey/endkey).

A view tree with multiple reducers where not all of them
are native (_count, _sum, _stats) or custom (JavaScript)
was not working anymore since the termless storage format,
and it became undetected for so long due to the fact that
old JavaScript testsuite (Futon) was removed (commit
304cbbd93400abfcb07ca70eecb4e1ccf3f3b485) and no equivalent
etap tests existed.
A view tree with multiple reducers only exists when 2 or
more views in the same design document have exactly the same
map function, on a byte by byte basis, and different reduce
functions (builtin or custom).
Change-Id: Id3218842da83e9e26339e6c59dd7c9b2e8d6a999
Reviewed-on: http://review.couchbase.org/25390
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>