MB-19093 [BP]: [ActiveStream] Address potential lock-inversion scenarios 98/62498/4
authorabhinavdangeti <abhinav@couchbase.com>
Fri, 15 Jan 2016 16:36:52 +0000 (08:36 -0800)
committerabhinav dangeti <abhinav@couchbase.com>
Thu, 7 Apr 2016 23:11:34 +0000 (23:11 +0000)
commit771859f815f3067ece19edbe588c2c852e100998
treeeece4c8efa8c4f6e9443e49b31c93435ea75fb1a
parent6811030fe7545943208c14f58211c237c228ea8b
MB-19093 [BP]: [ActiveStream] Address potential lock-inversion scenarios

Acquire vbucket state lock only when really necessary
in the ActiveStream context. Also avoid acquiring one
lock within the other wherever possible in the ActiveStream
context again.

This change is to avert potential deadlocks due to
lock inversion that will be induced by upcoming changes,
here are the scenarios:
(i)     Locking between streamsMutex, streamMutex and
        vb_stateLock in the set operation - handle
        response scenario.
        (http://factory.couchbase.com/job/ep-engine-threadsanitizer-master/1225/console)
(ii)    In case of a set operation, vb_stateLock is
        acquired and then streamMutex is acquired for
        notification. During markDiskSnapshot, the
        streamMutex is acquired before the vb_stateLock
        lock is acquired.
        (http://factory.couchbase.com/job/ep-engine-threadsanitizer-master/1268/console)

(Already reviewed at: http://review.couchbase.org/58557)

Change-Id: I5e5a3e2cc5ba9ae17090e1a3ee4bde100d305f1c
Reviewed-on: http://review.couchbase.org/62498
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
src/dcp-producer.cc
src/dcp-stream.cc