Skip to content

Commit 14dacbe

Browse files
author
Sriram Ganesan
committed
Synchronize access to cachedVBStates between a flusher task commit and a snapshot task
SUMMARY: ThreadSanitizer: data race /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/kvstore.cc:289 vbucket_state::toJSON() const ==================================== WARNING: ThreadSanitizer: data race (pid=209164) Read of size 8 at 0x7d1400009e50 by thread T16 (mutexes: write M16145): Previous write of size 8 at 0x7d1400009e50 by thread T18 (mutexes: write M16141): Change-Id: Ie5c41c4e4ba0219903b85047787ece373c6a8231 Reviewed-on: http://review.couchbase.org/65988 Reviewed-by: Dave Rigby <[email protected]> Tested-by: Sriram Ganesan <[email protected]>
1 parent 24c408e commit 14dacbe

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/forest-kvstore/forest-kvstore.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,8 @@ bool ForestKVStore::snapshotVBucket(uint16_t vbucketId, vbucket_state& vbstate,
14081408

14091409
hrtime_t start = gethrtime();
14101410

1411+
LockHolder lh(writerLock);
1412+
14111413
if (updateCachedVBState(vbucketId, vbstate) &&
14121414
(options == VBStatePersist::VBSTATE_PERSIST_WITHOUT_COMMIT ||
14131415
options == VBStatePersist::VBSTATE_PERSIST_WITH_COMMIT)) {
@@ -1423,7 +1425,6 @@ bool ForestKVStore::snapshotVBucket(uint16_t vbucketId, vbucket_state& vbstate,
14231425
statDoc.body = const_cast<char *>(stateStr.c_str());
14241426
statDoc.bodylen = stateStr.length();
14251427

1426-
LockHolder lh(writerLock);
14271428
fdb_status status = fdb_set(writeVbStateHandle, &statDoc);
14281429

14291430
if (status != FDB_RESULT_SUCCESS) {

0 commit comments

Comments
 (0)