Skip to content

Commit

Permalink
Some polish from feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
pdillinger committed May 23, 2023
1 parent 8e0022e commit db40f19
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions include/rocksdb/utilities/optimistic_transaction_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ enum class OccValidationPolicy {

class OccLockBuckets {
public:
// Most details in internal derived class
// Users should not derive from this class
// Most details in internal derived class.
// Users should not derive from this class.
virtual ~OccLockBuckets() {}

virtual size_t ApproximateMemoryUsage() const = 0;

private:
friend class OccLockBucketsImplBase;
OccLockBuckets() {}
};

// An object for sharing a pool of locks across DB instances.
Expand Down
2 changes: 2 additions & 0 deletions utilities/transactions/optimistic_transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ Status OptimisticTransaction::CommitWithParallelValidate() {
// In this way, txns from different threads all obey this rule so that
// deadlock can be avoided.
for (auto v : lk_ptrs) {
// WART: if an exception is thrown during a Lock(), previously locked will
// not be Unlock()ed. But a vector of MutexLock is likely inefficient.
v->Lock();
}
Defer unlocks([&]() {
Expand Down
2 changes: 1 addition & 1 deletion utilities/transactions/optimistic_transaction_db_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class OccLockBucketsImplBase : public OccLockBuckets {
template <bool cache_aligned>
class OccLockBucketsImpl : public OccLockBucketsImplBase {
public:
OccLockBucketsImpl(size_t bucket_count) : locks_(bucket_count) {}
explicit OccLockBucketsImpl(size_t bucket_count) : locks_(bucket_count) {}
port::Mutex& GetLockBucket(const Slice& key, uint64_t seed) override {
return locks_.Get(key, seed);
}
Expand Down

0 comments on commit db40f19

Please sign in to comment.