There are a number of parameters that can be used to help control errors and responses during a view query.
on_error
The on_error parameter specifies whether
the view results will be terminated on the first error from
a node, or whether individual nodes can fail and other nodes
return information.
When returning the information generated by a view request, the default response is for any raised error to be included as part of the JSON response, but for the view process to continue. This allows for individual nodes within the Couchbase cluster to timeout or fail, while still generating the requested view information.
In this instance, the error is included as part of the JSON returned:
{ "errors" : [ { "from" : "http://192.168.1.80:9503/_view_merge/?stale=false", "reason" : "req_timedout" }, { "from" : "http://192.168.1.80:9502/_view_merge/?stale=false", "reason" : "req_timedout" }, { "from" : "http://192.168.1.80:9501/_view_merge/?stale=false", "reason" : "req_timedout" } ], "rows" : [ { "value" : 333280, "key" : null } ] }
You can alter this behaviour by using the
on_error argument. The default value is
continue. If you set this value to
stop then the view response will cease
the moment an error occurs. The returned JSON will contain
the error information for the node that returned the first
error. For example:
{ "errors" : [ { "from" : "http://192.168.1.80:9501/_view_merge/?stale=false", "reason" : "req_timedout" } ], "rows" : [ { "value" : 333280, "key" : null } ] }