Merge remote-tracking branch 'couchbase/3.0.x' into sherlock 28/65328/2
authorDave Rigby <daver@couchbase.com>
Wed, 29 Jun 2016 09:17:13 +0000 (10:17 +0100)
committerDave Rigby <daver@couchbase.com>
Wed, 29 Jun 2016 09:47:05 +0000 (10:47 +0100)
* couchbase/3.0.x:
  MB-19359: [2] Address lock inversion with vb's state lock and snapshot lock
  MB-19359: [1] Address lock inversion with vb's state lock and snapshot lock

Change-Id: Ia068af9b26e8a4b980bf22341fa43ac5452aca60

1  2 
src/ep_engine.cc

@@@ -4323,10 -4223,12 +4323,11 @@@ ENGINE_ERROR_CODE EventuallyPersistentE
  
          uint64_t relHighSeqno = vb->getHighSeqno();
  
-         ReaderLockHolder rlh(vb->getStateLock());
+         // An atomic read of vbucket state without acquiring the
+         // reader lock for state should suffice here.
          if (vb->getState() != vbucket_state_active) {
 -            uint64_t snapshot_start, snapshot_end;
 -            vb->getCurrentSnapshot(snapshot_start, snapshot_end);
 -            relHighSeqno = snapshot_end;
 +            snapshot_info_t info = vb->checkpointManager.getSnapshotInfo();
 +            relHighSeqno = info.range.end;
          }
  
          char buffer[32];
          RCPtr<VBucket> vb = getVBucket(*itr);
          if (vb) {
              uint64_t relHighSeqno = vb->getHighSeqno();
-             ReaderLockHolder rlh(vb->getStateLock());
+             // An atomic read of vbucket state without acquiring the
+             // reader lock for state should suffice here.
              if (vb->getState() != vbucket_state_active) {
 -                uint64_t snapshot_start, snapshot_end;
 -                vb->getCurrentSnapshot(snapshot_start, snapshot_end);
 -                relHighSeqno = snapshot_end;
 +                snapshot_info_t info = vb->checkpointManager.getSnapshotInfo();
 +                relHighSeqno = info.range.end;
              }
  
              char buffer[32];