CBD-425 Better error logging of dynamic reduce function errors

Log an explicit message, with bucket name, ddoc id, view name,
input values, when the reduce function fails due to a runtime
error.

Change-Id: Idcf1318a5aa979bb436116eb22876fcb7e4c3a0e
Reviewed-on: http://review.couchbase.org/18410
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
CBD-386 / CBD-444 More reliable stale=false snapshot requests

When such group snapshot requests come, grab the sequence number
of all active partitions and reply to the caller immediately
if the those were already indexed, otherwise just store those
sequence numbers and unblock/reply to the caller once the index
is up to date regarding those sequence numbers.
Previously callers were unconditionally unblocked once the updater
finished, which was not semantically correct, specially if a request
came after the updater started (common in an heavy updates scenario
with multiple clients doing stale=false queries).

Callers will also be blocked if any of the active partitions are
paused for indexing, and unblocked once they are unpaused and the
currently indexed sequence numbers are greater or equal to the
sequence numbers the caller got when it made the group snapshot
request (CBD-386).

Change-Id: I2e852f8c6e87a6a9909908e2d931bab919e46085
Reviewed-on: http://review.couchbase.org/18411
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
MB-5930 Fix builtin _stats reduce

Code matches against atom ejson keys but ejson decode operations
always return binary ejson keys.

Change-Id: Ied114f073b035348d49942827a1e6e10fc3b5e03
Reviewed-on: http://review.couchbase.org/18440
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
CBD-457 Faster updater stop on state transitions

Currently on state transitions, we must stop and restart the updater.
We gracefully shutdown the updater, waiting for it to finish processing
its current batch (5000 docs or max of 512Kb of KV pairs). This can
take a significant time if the index has many views with very deep
btrees each, making ns_server wait a long time.

This change just shutdowns the updater, with the tradeoff of losing
at most 5 seconds of updates, which will be processed again when the
updater is restarted. This has no side effects other than some
recomputations.

Change-Id: I207a9dfaeefd8553f64df0a33cea00926cbdfd18
Reviewed-on: http://review.couchbase.org/18538
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
CBD-457 Ensure cleanup process stop is time bound

To avoid waiting for too long when state transitions are
requested. In practice stopping the cleanup process is always
fast, no matter how big the view btrees are.
This is just a safe measure to ensure we don't block partition
state transition callers (ns_server) for too long.

Change-Id: I0d42ba8ed8f11add5884fedafb0ae178ab0afe11
Reviewed-on: http://review.couchbase.org/18539
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
CBD-456 Separate document body and meta arguments to map function

Sends non-JSON values as byte arrays for the 'doc' argument.
Numbers and ascii text can be decoded trivially from this capability,
extending our support for legacy applications.

The document JSON format on the wire for the Admin server client
looks like this now:

    {
      "body":{"user":"data","_anything":"goes"},
      "meta":{"id":"mydocid"}
    }

Turns off support for _id lookups in include_docs queries, although
with server level include docs going away as well, this change should
be of little consequence. Include_docs is  not removed as it is used
heavily by tests, in the future it  will be renamed to x_include_docs
across both tests and query  parser, in order to reflect the non-
supported nature.

Ticket with the specifications document:
http://www.couchbase.com/issues/browse/CBD-456

Admin UI and ns_server changes are in this change:
http://review.couchbase.org/#change,18028

Depends on this change in testrunner for view tests:
http://review.couchbase.org/#change,17768

Squashed in an old patch: http://review.couchbase.org/#change,18111

TODO: EP engine doesn't need to check for _fields when  setting JSON
flag. This can be accomplished in a future patch.

Related issue (not addressed by this patch): views and _all_docs
output (as well as XDCR JSON format) needs to understand non-UTF8
keys: http://www.couchbase.com/issues/browse/CBD-453

Change-Id: Ic8e3c5be07bd59b08f618b6f735e46c96ee4c9f2
CBD-456 Alter couch tests to use the new doc format

This moves the tests over to the new JSON format.

Change-Id: Ife4315db7cb2b1ffb22da0b7bfabd4f60b43c4cf