CBSE-811:  merge couchdb changes to 2.1.1 branch for 2.2.0 patch

Change-Id: Iaadf9a68099486ff0043e1f577b49848e0b10a9d
Reviewed-on: http://review.couchbase.org/30292
Reviewed-by: Philip Labee <philip@couchbase.com>
Tested-by: Philip Labee <philip@couchbase.com>