Skip to content

Commit c2c3088

Browse files
BenHuddlestondaverigby
authored andcommitted
MB-33840: Revert "MB-33684: Convert VB::Manifest lock to folly::SharedMutex"
This reverts commit 0dfa085 and commit 27e3aa7. Change-Id: If45017cbe923908e1cd52884b5266c8134a4289f Reviewed-on: http://review.couchbase.org/107642 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent e54e950 commit c2c3088

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

engines/ep/src/collections/vbucket_manifest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,8 @@ boost::optional<std::vector<CollectionID>> Manifest::getCollectionsForScope(
871871
}
872872

873873
bool Manifest::operator==(const Manifest& rhs) const {
874-
mutex_type::ReadHolder readLock(rwlock);
875-
mutex_type::ReadHolder otherReadLock(rhs.rwlock);
874+
std::lock_guard<cb::ReaderLock> readLock(rwlock.reader());
875+
std::lock_guard<cb::ReaderLock> otherReadLock(rhs.rwlock.reader());
876876

877877
if (rhs.map.size() != map.size()) {
878878
return false;

engines/ep/src/collections/vbucket_manifest.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "systemevent.h"
2525

2626
#include <boost/optional/optional_fwd.hpp>
27-
#include <folly/SharedMutex.h>
2827
#include <platform/non_negative_counter.h>
2928
#include <platform/rwlock.h>
3029
#include <platform/sized_buffer.h>
@@ -34,7 +33,6 @@
3433
#include <list>
3534
#include <mutex>
3635
#include <set>
37-
#include <shared_mutex>
3836
#include <unordered_map>
3937

4038
class VBucket;
@@ -81,7 +79,6 @@ namespace VB {
8179
class Manifest {
8280
public:
8381
using container = ::std::unordered_map<CollectionID, ManifestEntry>;
84-
using mutex_type = folly::SharedMutex;
8582

8683
/**
8784
* RAII read locking for access to the Manifest.
@@ -98,7 +95,7 @@ class Manifest {
9895
*/
9996
ReadHandle() = default;
10097

101-
ReadHandle(const Manifest* m, mutex_type& lock)
98+
ReadHandle(const Manifest* m, cb::RWLock& lock)
10299
: readLock(lock), manifest(m) {
103100
}
104101

@@ -260,7 +257,7 @@ class Manifest {
260257
protected:
261258
friend std::ostream& operator<<(std::ostream& os,
262259
const Manifest::ReadHandle& readHandle);
263-
std::shared_lock<mutex_type> readLock;
260+
std::unique_lock<cb::ReaderLock> readLock;
264261
const Manifest* manifest;
265262
};
266263

@@ -292,7 +289,7 @@ class Manifest {
292289
* should not be allowed, whereas a disk backfill is allowed
293290
*/
294291
CachingReadHandle(const Manifest* m,
295-
mutex_type& lock,
292+
cb::RWLock& lock,
296293
DocKey key,
297294
bool allowSystem)
298295
: ReadHandle(m, lock),
@@ -469,7 +466,7 @@ class Manifest {
469466
*/
470467
class StatsReadHandle : private ReadHandle {
471468
public:
472-
StatsReadHandle(const Manifest* m, mutex_type& lock, CollectionID cid)
469+
StatsReadHandle(const Manifest* m, cb::RWLock& lock, CollectionID cid)
473470
: ReadHandle(m, lock), itr(m->getManifestIterator(cid)) {
474471
}
475472

@@ -503,7 +500,7 @@ class Manifest {
503500
*/
504501
class WriteHandle {
505502
public:
506-
WriteHandle(Manifest& m, mutex_type& lock)
503+
WriteHandle(Manifest& m, cb::RWLock& lock)
507504
: writeLock(lock), manifest(m) {
508505
}
509506

@@ -644,7 +641,7 @@ class Manifest {
644641
}
645642

646643
private:
647-
mutex_type::WriteHolder writeLock;
644+
std::unique_lock<cb::WriterLock> writeLock;
648645
Manifest& manifest;
649646
};
650647

@@ -1256,7 +1253,7 @@ class Manifest {
12561253
/**
12571254
* shared lock to allow concurrent readers and safe updates
12581255
*/
1259-
mutable mutex_type rwlock;
1256+
mutable cb::RWLock rwlock;
12601257

12611258
friend std::ostream& operator<<(std::ostream& os, const Manifest& manifest);
12621259

engines/ep/tests/module_tests/collections/vbucket_manifest_test.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ class MockVBManifest : public Collections::VB::Manifest {
3737
}
3838

3939
bool exists(CollectionID identifier) const {
40-
mutex_type::ReadHolder readLock(rwlock);
40+
std::lock_guard<cb::ReaderLock> readLock(rwlock.reader());
4141
return exists_UNLOCKED(identifier);
4242
}
4343

4444
size_t size() const {
45-
mutex_type::ReadHolder readLock(rwlock);
45+
std::lock_guard<cb::ReaderLock> readLock(rwlock.reader());
4646
return map.size();
4747
}
4848

4949
bool compareEntry(CollectionID id,
5050
const Collections::VB::ManifestEntry& entry,
5151
bool ignoreHighSeqno = false) const {
52-
mutex_type::ReadHolder readLock(rwlock);
52+
std::lock_guard<cb::ReaderLock> readLock(rwlock.reader());
5353
if (exists_UNLOCKED(id)) {
5454
auto itr = map.find(id);
5555
const auto& myEntry = itr->second;
@@ -75,7 +75,7 @@ class MockVBManifest : public Collections::VB::Manifest {
7575
}
7676

7777
bool operator==(const MockVBManifest& rhs) const {
78-
mutex_type::ReadHolder readLock(rwlock);
78+
std::lock_guard<cb::ReaderLock> readLock(rwlock.reader());
7979
if (rhs.size() != size()) {
8080
return false;
8181
}

0 commit comments

Comments
 (0)