MB-19982: Don't hold connsLock for duration of dcp stats 11/65211/12
authorJim Walker <jim@couchbase.com>
Fri, 24 Jun 2016 12:28:34 +0000 (12:28 +0000)
committerDave Rigby <daver@couchbase.com>
Tue, 28 Jun 2016 14:18:56 +0000 (14:18 +0000)
commitdd3b6ae5e919bf51adaf5183fc8f1a076eac5357
tree0c9bff16392ff9f88c7f1560565a8f25578adbe3
parent65bbce36a558ad0d50da29ddaa115c7133bb2261
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>
src/connmap.h
src/ep_engine.cc
tests/ep_testsuite.cc