Run clang-format on utilities/transactions (#10871)

Summary:
This PR is the result of running the following command
```
find ./utilities/transactions/ -name '*.cc' -o -name '*.h' -o -name '*.c' -o -name '*.hpp' -o -name '*.cpp' | xargs clang-format -i
```

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10871

Test Plan: make check

Reviewed By: cbi42

Differential Revision: D40686871

Pulled By: riversand963

fbshipit-source-id: 613738d667ec8f8e13cce4802e0e166d6be52211
main
Yanqin Jin 2 years ago committed by Facebook GitHub Bot
parent 84563a2701
commit 95a1935cb1
  1. 14
      utilities/transactions/lock/point/point_lock_manager.cc
  2. 5
      utilities/transactions/lock/point/point_lock_manager.h
  3. 11
      utilities/transactions/lock/range/range_locking_test.cc
  4. 3
      utilities/transactions/lock/range/range_tree/lib/locktree/locktree.cc
  5. 2
      utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h
  6. 2
      utilities/transactions/optimistic_transaction.h
  7. 2
      utilities/transactions/optimistic_transaction_db_impl.h
  8. 5
      utilities/transactions/optimistic_transaction_test.cc
  9. 3
      utilities/transactions/transaction_base.cc
  10. 5
      utilities/transactions/transaction_base.h
  11. 10
      utilities/transactions/transaction_test.cc
  12. 7
      utilities/transactions/write_prepared_transaction_test.cc
  13. 4
      utilities/transactions/write_prepared_txn.cc
  14. 9
      utilities/transactions/write_prepared_txn_db.cc
  15. 2
      utilities/transactions/write_unprepared_transaction_test.cc
  16. 1
      utilities/transactions/write_unprepared_txn_db.cc

@ -334,10 +334,10 @@ Status PointLockManager::AcquireWithTimeout(
} }
if (result.IsTimedOut()) { if (result.IsTimedOut()) {
timed_out = true; timed_out = true;
// Even though we timed out, we will still make one more attempt to // Even though we timed out, we will still make one more attempt to
// acquire lock below (it is possible the lock expired and we // acquire lock below (it is possible the lock expired and we
// were never signaled). // were never signaled).
} }
if (result.ok() || result.IsTimedOut()) { if (result.ok() || result.IsTimedOut()) {
@ -379,8 +379,10 @@ bool PointLockManager::IncrementWaiters(
const autovector<TransactionID>& wait_ids, const std::string& key, const autovector<TransactionID>& wait_ids, const std::string& key,
const uint32_t& cf_id, const bool& exclusive, Env* const env) { const uint32_t& cf_id, const bool& exclusive, Env* const env) {
auto id = txn->GetID(); auto id = txn->GetID();
std::vector<int> queue_parents(static_cast<size_t>(txn->GetDeadlockDetectDepth())); std::vector<int> queue_parents(
std::vector<TransactionID> queue_values(static_cast<size_t>(txn->GetDeadlockDetectDepth())); static_cast<size_t>(txn->GetDeadlockDetectDepth()));
std::vector<TransactionID> queue_values(
static_cast<size_t>(txn->GetDeadlockDetectDepth()));
std::lock_guard<std::mutex> lock(wait_txn_map_mutex_); std::lock_guard<std::mutex> lock(wait_txn_map_mutex_);
assert(!wait_txn_map_.Contains(id)); assert(!wait_txn_map_.Contains(id));

@ -203,9 +203,8 @@ class PointLockManager : public LockManager {
LockInfo&& lock_info); LockInfo&& lock_info);
Status AcquireLocked(LockMap* lock_map, LockMapStripe* stripe, Status AcquireLocked(LockMap* lock_map, LockMapStripe* stripe,
const std::string& key, Env* env, const std::string& key, Env* env, LockInfo&& lock_info,
LockInfo&& lock_info, uint64_t* wait_time, uint64_t* wait_time, autovector<TransactionID>* txn_ids);
autovector<TransactionID>* txn_ids);
void UnLockKey(PessimisticTransaction* txn, const std::string& key, void UnLockKey(PessimisticTransaction* txn, const std::string& key,
LockMapStripe* stripe, LockMap* lock_map, Env* env); LockMapStripe* stripe, LockMap* lock_map, Env* env);

@ -142,20 +142,18 @@ TEST_F(RangeLockingTest, UpgradeLockAndGetConflict) {
auto cf = db->DefaultColumnFamily(); auto cf = db->DefaultColumnFamily();
Status s; Status s;
std::string value; std::string value;
txn_options.lock_timeout= 10; txn_options.lock_timeout = 10;
Transaction* txn0 = db->BeginTransaction(write_options, txn_options); Transaction* txn0 = db->BeginTransaction(write_options, txn_options);
Transaction* txn1 = db->BeginTransaction(write_options, txn_options); Transaction* txn1 = db->BeginTransaction(write_options, txn_options);
// Get the shared lock in txn0 // Get the shared lock in txn0
s = txn0->GetForUpdate(ReadOptions(), cf, s = txn0->GetForUpdate(ReadOptions(), cf, Slice("a"), &value,
Slice("a"), &value, false /*exclusive*/);
false /*exclusive*/);
ASSERT_TRUE(s.IsNotFound()); ASSERT_TRUE(s.IsNotFound());
// Get the shared lock on the same key in txn1 // Get the shared lock on the same key in txn1
s = txn1->GetForUpdate(ReadOptions(), cf, s = txn1->GetForUpdate(ReadOptions(), cf, Slice("a"), &value,
Slice("a"), &value,
false /*exclusive*/); false /*exclusive*/);
ASSERT_TRUE(s.IsNotFound()); ASSERT_TRUE(s.IsNotFound());
@ -170,7 +168,6 @@ TEST_F(RangeLockingTest, UpgradeLockAndGetConflict) {
delete txn1; delete txn1;
} }
TEST_F(RangeLockingTest, SnapshotValidation) { TEST_F(RangeLockingTest, SnapshotValidation) {
Status s; Status s;
Slice key_slice = Slice("k"); Slice key_slice = Slice("k");

@ -199,8 +199,7 @@ static bool determine_conflicting_txnids(
if (other_txnid == TXNID_SHARED) { if (other_txnid == TXNID_SHARED) {
// Add all shared lock owners, except this transaction. // Add all shared lock owners, except this transaction.
for (TXNID shared_id : *lock.owners) { for (TXNID shared_id : *lock.owners) {
if (shared_id != txnid) if (shared_id != txnid) conflicts->add(shared_id);
conflicts->add(shared_id);
} }
} else { } else {
conflicts->add(other_txnid); conflicts->add(other_txnid);

@ -129,7 +129,7 @@ static inline tokutime_t toku_time_now(void) {
return (uint64_t)hi << 32 | lo; return (uint64_t)hi << 32 | lo;
#elif defined(__aarch64__) #elif defined(__aarch64__)
uint64_t result; uint64_t result;
__asm __volatile__("mrs %[rt], cntvct_el0" : [ rt ] "=r"(result)); __asm __volatile__("mrs %[rt], cntvct_el0" : [rt] "=r"(result));
return result; return result;
#elif defined(__powerpc__) #elif defined(__powerpc__)
return __ppc_get_timebase(); return __ppc_get_timebase();

@ -18,8 +18,8 @@
#include "rocksdb/snapshot.h" #include "rocksdb/snapshot.h"
#include "rocksdb/status.h" #include "rocksdb/status.h"
#include "rocksdb/types.h" #include "rocksdb/types.h"
#include "rocksdb/utilities/transaction.h"
#include "rocksdb/utilities/optimistic_transaction_db.h" #include "rocksdb/utilities/optimistic_transaction_db.h"
#include "rocksdb/utilities/transaction.h"
#include "rocksdb/utilities/write_batch_with_index.h" #include "rocksdb/utilities/write_batch_with_index.h"
#include "utilities/transactions/transaction_base.h" #include "utilities/transactions/transaction_base.h"
#include "utilities/transactions/transaction_util.h" #include "utilities/transactions/transaction_util.h"

@ -6,9 +6,9 @@
#pragma once #pragma once
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
#include <algorithm>
#include <mutex> #include <mutex>
#include <vector> #include <vector>
#include <algorithm>
#include "rocksdb/db.h" #include "rocksdb/db.h"
#include "rocksdb/options.h" #include "rocksdb/options.h"

@ -53,7 +53,7 @@ class OptimisticTransactionTest
Open(); Open();
} }
private: private:
void Open() { void Open() {
ColumnFamilyOptions cf_options(options); ColumnFamilyOptions cf_options(options);
OptimisticTransactionDBOptions occ_opts; OptimisticTransactionDBOptions occ_opts;
@ -1426,7 +1426,8 @@ TEST_P(OptimisticTransactionTest, SequenceNumberAfterRecoverTest) {
WriteOptions write_options; WriteOptions write_options;
OptimisticTransactionOptions transaction_options; OptimisticTransactionOptions transaction_options;
Transaction* transaction(txn_db->BeginTransaction(write_options, transaction_options)); Transaction* transaction(
txn_db->BeginTransaction(write_options, transaction_options));
Status s = transaction->Put("foo", "val"); Status s = transaction->Put("foo", "val");
ASSERT_OK(s); ASSERT_OK(s);
s = transaction->Put("foo2", "val"); s = transaction->Put("foo2", "val");

@ -209,8 +209,7 @@ Status TransactionBaseImpl::RollbackToSavePoint() {
} }
Status TransactionBaseImpl::PopSavePoint() { Status TransactionBaseImpl::PopSavePoint() {
if (save_points_ == nullptr || if (save_points_ == nullptr || save_points_->empty()) {
save_points_->empty()) {
// No SavePoint yet. // No SavePoint yet.
assert(write_batch_.PopSavePoint().IsNotFound()); assert(write_batch_.PopSavePoint().IsNotFound());
return Status::NotFound(); return Status::NotFound();

@ -93,8 +93,9 @@ class TransactionBaseImpl : public Transaction {
std::vector<Status> MultiGet(const ReadOptions& options, std::vector<Status> MultiGet(const ReadOptions& options,
const std::vector<Slice>& keys, const std::vector<Slice>& keys,
std::vector<std::string>* values) override { std::vector<std::string>* values) override {
return MultiGet(options, std::vector<ColumnFamilyHandle*>( return MultiGet(options,
keys.size(), db_->DefaultColumnFamily()), std::vector<ColumnFamilyHandle*>(
keys.size(), db_->DefaultColumnFamily()),
keys, values); keys, values);
} }

@ -2490,7 +2490,7 @@ TEST_P(TransactionTest, FlushTest2) {
ASSERT_OK(s); ASSERT_OK(s);
ASSERT_EQ("z", value); ASSERT_EQ("z", value);
delete txn; delete txn;
} }
} }
@ -2967,9 +2967,9 @@ TEST_P(TransactionTest, MultiGetLargeBatchedTest) {
std::vector<PinnableSlice> values(keys.size()); std::vector<PinnableSlice> values(keys.size());
std::vector<Status> statuses(keys.size()); std::vector<Status> statuses(keys.size());
wb.MultiGetFromBatchAndDB(db, snapshot_read_options, handles[1], keys.size(), keys.data(), wb.MultiGetFromBatchAndDB(db, snapshot_read_options, handles[1], keys.size(),
values.data(), statuses.data(), false); keys.data(), values.data(), statuses.data(), false);
for (size_t i =0; i < keys.size(); ++i) { for (size_t i = 0; i < keys.size(); ++i) {
if (i == 1) { if (i == 1) {
ASSERT_TRUE(statuses[1].IsNotFound()); ASSERT_TRUE(statuses[1].IsNotFound());
} else if (i == 2) { } else if (i == 2) {
@ -4674,7 +4674,7 @@ TEST_P(TransactionTest, TimeoutTest) {
ASSERT_OK(s); ASSERT_OK(s);
TransactionOptions txn_options0; TransactionOptions txn_options0;
txn_options0.expiration = 100; // 100ms txn_options0.expiration = 100; // 100ms
txn_options0.lock_timeout = 50; // txn timeout no longer infinite txn_options0.lock_timeout = 50; // txn timeout no longer infinite
Transaction* txn1 = db->BeginTransaction(write_options, txn_options0); Transaction* txn1 = db->BeginTransaction(write_options, txn_options0);

@ -2120,7 +2120,7 @@ TEST_P(WritePreparedTransactionTest, IsInSnapshot) {
seq++; seq++;
cur_txn = seq; cur_txn = seq;
wp_db->AddPrepared(cur_txn); wp_db->AddPrepared(cur_txn);
} else { // else commit it } else { // else commit it
seq++; seq++;
wp_db->AddCommitted(cur_txn, seq); wp_db->AddCommitted(cur_txn, seq);
wp_db->RemovePrepared(cur_txn); wp_db->RemovePrepared(cur_txn);
@ -3445,9 +3445,8 @@ TEST_P(WritePreparedTransactionTest, Iterate) {
auto* txn = db->BeginTransaction(WriteOptions()); auto* txn = db->BeginTransaction(WriteOptions());
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
Iterator* iter = (i == 0) Iterator* iter = (i == 0) ? db->NewIterator(ReadOptions())
? db->NewIterator(ReadOptions()) : txn->GetIterator(ReadOptions());
: txn->GetIterator(ReadOptions());
// Seek // Seek
iter->Seek("foo"); iter->Seek("foo");
verify_state(iter, "foo", expected_val); verify_state(iter, "foo", expected_val);

@ -115,8 +115,8 @@ Status WritePreparedTxn::PrepareInternal() {
// For each duplicate key we account for a new sub-batch // For each duplicate key we account for a new sub-batch
prepare_batch_cnt_ = GetWriteBatch()->SubBatchCnt(); prepare_batch_cnt_ = GetWriteBatch()->SubBatchCnt();
// Having AddPrepared in the PreReleaseCallback allows in-order addition of // Having AddPrepared in the PreReleaseCallback allows in-order addition of
// prepared entries to PreparedHeap and hence enables an optimization. Refer to // prepared entries to PreparedHeap and hence enables an optimization. Refer
// SmallestUnCommittedSeq for more details. // to SmallestUnCommittedSeq for more details.
AddPreparedCallback add_prepared_callback( AddPreparedCallback add_prepared_callback(
wpt_db_, db_impl_, prepare_batch_cnt_, wpt_db_, db_impl_, prepare_batch_cnt_,
db_impl_->immutable_db_options().two_write_queues, kFirstPrepareBatch); db_impl_->immutable_db_options().two_write_queues, kFirstPrepareBatch);

@ -309,7 +309,6 @@ void WritePreparedTxnDB::UpdateCFComparatorMap(ColumnFamilyHandle* h) {
handle_map_.reset(handle_map); handle_map_.reset(handle_map);
} }
std::vector<Status> WritePreparedTxnDB::MultiGet( std::vector<Status> WritePreparedTxnDB::MultiGet(
const ReadOptions& options, const ReadOptions& options,
const std::vector<ColumnFamilyHandle*>& column_family, const std::vector<ColumnFamilyHandle*>& column_family,
@ -608,7 +607,8 @@ void WritePreparedTxnDB::RemovePrepared(const uint64_t prepare_seq,
bool WritePreparedTxnDB::GetCommitEntry(const uint64_t indexed_seq, bool WritePreparedTxnDB::GetCommitEntry(const uint64_t indexed_seq,
CommitEntry64b* entry_64b, CommitEntry64b* entry_64b,
CommitEntry* entry) const { CommitEntry* entry) const {
*entry_64b = commit_cache_[static_cast<size_t>(indexed_seq)].load(std::memory_order_acquire); *entry_64b = commit_cache_[static_cast<size_t>(indexed_seq)].load(
std::memory_order_acquire);
bool valid = entry_64b->Parse(indexed_seq, entry, FORMAT); bool valid = entry_64b->Parse(indexed_seq, entry, FORMAT);
return valid; return valid;
} }
@ -617,8 +617,9 @@ bool WritePreparedTxnDB::AddCommitEntry(const uint64_t indexed_seq,
const CommitEntry& new_entry, const CommitEntry& new_entry,
CommitEntry* evicted_entry) { CommitEntry* evicted_entry) {
CommitEntry64b new_entry_64b(new_entry, FORMAT); CommitEntry64b new_entry_64b(new_entry, FORMAT);
CommitEntry64b evicted_entry_64b = commit_cache_[static_cast<size_t>(indexed_seq)].exchange( CommitEntry64b evicted_entry_64b =
new_entry_64b, std::memory_order_acq_rel); commit_cache_[static_cast<size_t>(indexed_seq)].exchange(
new_entry_64b, std::memory_order_acq_rel);
bool valid = evicted_entry_64b.Parse(indexed_seq, evicted_entry, FORMAT); bool valid = evicted_entry_64b.Parse(indexed_seq, evicted_entry, FORMAT);
return valid; return valid;
} }

@ -28,7 +28,7 @@ class WriteUnpreparedTransactionTest
WriteUnpreparedTransactionTest() WriteUnpreparedTransactionTest()
: WriteUnpreparedTransactionTestBase(std::get<0>(GetParam()), : WriteUnpreparedTransactionTestBase(std::get<0>(GetParam()),
std::get<1>(GetParam()), std::get<1>(GetParam()),
std::get<2>(GetParam())){} std::get<2>(GetParam())) {}
}; };
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(

@ -6,6 +6,7 @@
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
#include "utilities/transactions/write_unprepared_txn_db.h" #include "utilities/transactions/write_unprepared_txn_db.h"
#include "db/arena_wrapped_db_iter.h" #include "db/arena_wrapped_db_iter.h"
#include "rocksdb/utilities/transaction_db.h" #include "rocksdb/utilities/transaction_db.h"
#include "util/cast_util.h" #include "util/cast_util.h"

Loading…
Cancel
Save