[MB-6895] [RN 2.0.1] Map function failure in a view for a document causes it to be unavailable for all other views in the design document Created: 12/Oct/12  Updated: 06/Mar/13  Resolved: 06/Mar/13

Status: Closed
Project: Couchbase Server
Component/s: documentation
Affects Version/s: 2.0
Fix Version/s: 2.0.1
Security Level: Public

Type: Bug Priority: Blocker
Reporter: Deepkaran Salooja Assignee: kzeller
Resolution: Fixed Votes: 1
Labels: 2.0-release-notes, customer
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

As per Filipe's comments:

One thing to note is, when the map function of a view fails with a document X, map results for other views of the same design document won't be computed for that same document X.
Only way to avoid this is by having the views in different design documents. This is a limitation inherited from Apache CouchDB, maybe we can get rid of it post 2.0.

This can be little confusing for the users as views appear to be independent of each other.

See http://www.couchbase.com/issues/browse/CBSE-238 for an example case.

 Comments   
Comment by Farshid Ghods (Inactive) [ 15/Oct/12 ]
Dipti,

should we assign this to MC for documentation ?
Comment by Dipti Borkar [ 16/Oct/12 ]
I consider this a bug. Filipe, can you provide feedback on how this can be fixed?

In this case, why did the view fail in the first case?
Comment by Filipe Manana (Inactive) [ 16/Oct/12 ]
This is not a trivial change to do, and I think it's a bit late to do it.

Not sure if I understand your question about why it failed.
It's a map function run time error for a particular document, we log/report the error and move on. And, results for other views in the same design document for that particular document are not considered.
CouchDB has had this behaviour for years, I don't remember it being otherwise.
Comment by Volker Mische [ 16/Oct/12 ]
It's a bit like a compiler, if one source file fails, the program can't be build. The solution: fix your map functions.
Comment by Dipti Borkar [ 18/Oct/12 ]
The solution cannot be fix your map functions. Its very non-intuitive behavior for a database and makes development tough.

Will need to fix in 2.0.1.
Comment by Dipti Borkar [ 28/Oct/12 ]
where is the mapreduce_errors file located?
Comment by Filipe Manana (Inactive) [ 28/Oct/12 ]
For development builds at least, it's in the same directory as all other log files.
Comment by Steve Yen [ 26/Nov/12 ]
bug-scrub: keeping in 2.0.1 for now, as two customers have reported running into this -- adoption issue.
Comment by Volker Mische [ 18/Jan/13 ]
Moving to 2.0.2, it's out of scope for 2.0.1.

Filipe, feel free to move back if you don't agree.
Comment by Dipti Borkar [ 20/Jan/13 ]
Need to move back as its a customer issue and a community issue hit by several folks. As discussed in the bug scrub on Friday, this is a blocker for 2.0.1.
If we cannot make it in this coming week, we can revisit.
Comment by Dipti Borkar [ 24/Jan/13 ]
per bug-scrub: Filipe: I think you have made progress on this. Can you please update the bug re:fix?
Comment by Dipti Borkar [ 24/Jan/13 ]
We are trying to lock-down functional bugs by Friday.
Comment by Filipe Manana (Inactive) [ 25/Jan/13 ]
http://review.couchbase.org/#/c/24205/
http://review.couchbase.org/#/c/24206/
Comment by Dipti Borkar [ 25/Jan/13 ]
Thanks :-)
Comment by Filipe Manana (Inactive) [ 28/Jan/13 ]
merged
Comment by Thuan Nguyen [ 28/Jan/13 ]
Integrated in github-couchdb-preview #558 (See [http://qa.hq.northscale.net/job/github-couchdb-preview/558/])
    MB-6895 Better map function error isolation (Revision cb32250806b28e9df6892f0ce652a9cb51949738)

     Result = SUCCESS
Filipe David Borba Manana :
Files :
* src/couchdb/couch_view_updater.erl
* src/mapreduce/win32/mapreduce.vcxproj.tpl.in
* src/mapreduce/mapreduce.cc
* src/couch_set_view/test/12-errors.t
* src/mapreduce/mapreduce.h
* src/mapreduce/Makefile.am
* src/mapreduce/test/01-map.t
* src/mapreduce/mapreduce_nif.cc
* src/mapreduce/nif_stl_allocator.h
* src/couch_set_view/src/couch_set_view_updater.erl
Comment by Deepkaran Salooja [ 07/Feb/13 ]
For dev-subset queries, with one view having error in mapfuction is causing other views not to give results. Working fine for production/fullset queries.

1. Install 2.0.1-150-rel
2. Create default bucket, load 100000 items using mcsoda
3. Create 1 ddoc, 2 views with view v1 defined to generate run-time error:

curl -X PUT -H 'Content-Type: application/json' 'http://Administrator:password@10.3.3.95:8092/default/_design/dev_d1' \
   -d '{"views":{"v1":{"map":"function(doc, meta){\nemit(doc.foo.bar, null);\n}"}, "v2":{"map":"function(doc, meta){\nemit(meta.id, doc.name);\n}"}}}'

4. Query the views:

Development subset:

Expected error for v1 -
curl -X GET 'http://10.3.3.95:8092/default/_design/dev_d1/_view/v1?stale=false&limit=10'
{"total_rows":0,"rows":[
],
"errors":[
{"from":"local","reason":"{function_clause,\n [{couch_view_mapreduce,'-map/1-lc$^1/1-1-',\n [{error,<<\"TypeError: Cannot read property 'bar' of undefined\">>}]},\n {couch_view_mapreduce,'-map/1-lc$^0/1-0-',1},\n {couch_view_mapreduce,map,1},\n {couch_view_updater,'-do_maps/5-fun-1-',5},\n {couch_view_updater,do_maps,5},\n {couch_view_updater,'-update/3-fun-0-',3}]}"}
]
}

Unexpected error for v2 -
curl -X GET 'http://10.3.3.95:8092/default/_design/dev_d1/_view/v2?stale=false&limit=10&#39;
{"total_rows":0,"rows":[
],
"errors":[
{"from":"local","reason":"{function_clause,\n [{couch_view_mapreduce,'-map/1-lc$^1/1-1-',\n [{error,<<\"TypeError: Cannot read property 'bar' of undefined\">>}]},\n {couch_view_mapreduce,'-map/1-lc$^0/1-0-',1},\n {couch_view_mapreduce,map,1},\n {couch_view_updater,'-do_maps/5-fun-1-',5},\n {couch_view_updater,do_maps,5},\n {couch_view_updater,'-update/3-fun-0-',3}]}"}
]
}


Fullset:

curl -X GET 'http://10.3.3.95:8092/default/_design/dev_d1/_view/v1?stale=false&limit=10&full_set=true&#39;
{"total_rows":0,"rows":[
]
}

curl -X GET 'http://10.3.3.95:8092/default/_design/dev_d1/_view/v2?stale=false&limit=10&full_set=true&#39;

{"total_rows":100002,"rows":[
{"id":"70one-00003e3b9e533668","key":"70one-00003e3b9e533668","value":null},
{"id":"70one-000053b1e684c9e7","key":"70one-000053b1e684c9e7","value":null},
{"id":"70one-00029153d12ae1c9","key":"70one-00029153d12ae1c9","value":null},
{"id":"70one-0002ac0d783338cf","key":"70one-0002ac0d783338cf","value":null},
{"id":"70one-0004d0b59e19461f","key":"70one-0004d0b59e19461f","value":null},
{"id":"70one-00053f5e11d1fe4e","key":"70one-00053f5e11d1fe4e","value":null},
{"id":"70one-00056c20eb5a0295","key":"70one-00056c20eb5a0295","value":null},
{"id":"70one-0006246bee639c7a","key":"70one-0006246bee639c7a","value":null},
{"id":"70one-00063cb5da1826fe","key":"70one-00063cb5da1826fe","value":null},
{"id":"70one-0006aabe0ba47a35","key":"70one-0006aabe0ba47a35","value":null}
]
}
Comment by Filipe Manana (Inactive) [ 07/Feb/13 ]
http://review.couchbase.org/#/c/24474/

Doh, this is what happens when there are 3 different view engines.
Also, for spatial (GeoCouch) views, the old behaviour is expected - it will change only when it migrates to the superstart tree structure as production views.

Try the next build with that change merged.
thanks
Comment by Thuan Nguyen [ 07/Feb/13 ]
Integrated in github-couchdb-preview #561 (See [http://qa.hq.northscale.net/job/github-couchdb-preview/561/])
    MB-6895 Fix badmatch on error (Revision da000c225be6ad4821bda8212c27190ecdbe3284)

     Result = SUCCESS
Filipe David Borba Manana :
Files :
* src/couchdb/couch_view_mapreduce.erl
Comment by Thuan Nguyen [ 09/Feb/13 ]
Integrated in github-couchdb-preview #562 (See [http://qa.hq.northscale.net/job/github-couchdb-preview/562/])
    MB-6895 Correct error processing for dev views (Revision 356ef20516464c5bd0c22dec643bd27fba618d18)

     Result = SUCCESS
Filipe David Borba Manana :
Files :
* src/couchdb/couch_view_mapreduce.erl
Comment by Dipti Borkar [ 11/Feb/13 ]
assuming this was because dev views use stock couch. So Filipe, does your comment mean that you fixed it for 2.0.1?
Comment by Deepkaran Salooja [ 11/Feb/13 ]
Verified with build 2.0.1-153-rel.
Comment by kzeller [ 06/Mar/13 ]
Added to RN 2.0.1:

<rnentry type="fix">

<version ver="2.0.0l"/>

<class id="index"/>

<issue type="cb" ref="MB-6895"/>


<rntext>

<para>
In past releases of Couchbase Server 2.0, if you had a map function that failed to index, other functions in the same
design document would also fail. This has been fixed.
</para>


</rntext>

</rnentry>
Comment by kzeller [ 06/Mar/13 ]
Added to RN 2.0.1:

<rnentry type="fix">

<version ver="2.0.0l"/>

<class id="index"/>

<issue type="cb" ref="MB-6895"/>


<rntext>

<para>
In past releases of Couchbase Server 2.0, if you had a map function that failed to index, other functions in the same
design document would also fail. This has been fixed.
</para>


</rntext>

</rnentry>
Generated at Thu Dec 18 03:20:59 CST 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.