MB-19982: Don't hold connsLock for duration of dcp stats
The Mb identified a lock inversion between dcp->set_vbucket_state
and get_stats("dcp")
The get_stats path uses doDcpStats which holds connsLock whilst
all connections are visited and their stats gathered. When getting
a PassiveStream's stats the buffer.mutex is needed.
The set_vbucket_state obtains the same locks in the reverse order.
Whilst buffer.mutex is held it will try to get connsLock
(via EventuallyPersistentStore::setVBucketState calling into dcpConnMap).
The fix is to work on a copy of the "all" list so that we can do the
work without the lock.
ref-counted pointers should stop any issues where the connection
being visited is freed/dropped from another thread.
Change-Id: Iff5f7be1d78278a4b00bb07b859697cca3115299
Reviewed-on: http://review.couchbase.org/65211
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: buildbot <build@couchbase.com>