diff --git a/src/concurrency_control/bg_work/bg_commit.cpp b/src/concurrency_control/bg_work/bg_commit.cpp index c4cf20f00..7795b7abd 100644 --- a/src/concurrency_control/bg_work/bg_commit.cpp +++ b/src/concurrency_control/bg_work/bg_commit.cpp @@ -72,6 +72,14 @@ void bg_commit::worker() { REFIND : // NOLINT { std::shared_lock lk1{mtx_cont_wait_tx()}; + // if cont empty then clear used_ids + if (cont_wait_tx().empty()) { + { + std::unique_lock lk2{mtx_used_ids()}; + if (!used_ids().empty()) { used_ids().clear(); } + } + continue; + } auto itr = cont_wait_tx().begin(); for (; itr != cont_wait_tx().end(); ++itr) { token = std::get<1>(*itr); @@ -125,11 +133,6 @@ void bg_commit::worker() { * than this transaction wait for the result of this * transaction. */ - // erase from used_ids - { - std::unique_lock lk2{mtx_used_ids()}; - used_ids().erase(tx_id); - } goto REFIND; // NOLINT } // termination was successed ti->set_result_requested_commit(rc); @@ -138,11 +141,6 @@ void bg_commit::worker() { { std::lock_guard lk1{mtx_cont_wait_tx()}; cont_wait_tx().erase(std::make_tuple(tx_id, token)); - // erase from used_ids - { - std::unique_lock lk2{mtx_used_ids()}; - used_ids().erase(tx_id); - } } goto REFIND; // NOLINT diff --git a/src/concurrency_control/include/tid.h b/src/concurrency_control/include/tid.h index 9840416ba..b0dd01ea4 100644 --- a/src/concurrency_control/include/tid.h +++ b/src/concurrency_control/include/tid.h @@ -114,7 +114,7 @@ class tid_word { // NOLINT void display(); - void lock(bool by_gc = false); + void lock(bool by_gc = false); // NOLINT /** * @pre This is called after lock() function. diff --git a/src/concurrency_control/ongoing_tx.cpp b/src/concurrency_control/ongoing_tx.cpp index 6b920cd1f..705d5858e 100644 --- a/src/concurrency_control/ongoing_tx.cpp +++ b/src/concurrency_control/ongoing_tx.cpp @@ -146,7 +146,6 @@ bool ongoing_tx::exist_wait_for(session* ti, Status& out_status) { std::size_t id = ti->get_long_tx_id(); bool has_wp = !ti->get_wp_set().empty(); auto wait_for = ti->extract_wait_for(); - // TODO wait_for empty return false. // check local write set std::set st_set{}; // create and compaction about storage set diff --git a/test/concurrency_control/long_tx/insert/long_insert_insert_conflict_diff_epoch_same_key_co_low_high_test.cpp b/test/concurrency_control/long_tx/insert/long_insert_insert_conflict_diff_epoch_same_key_co_low_high_test.cpp index f18cd32bc..f5c9a0f88 100644 --- a/test/concurrency_control/long_tx/insert/long_insert_insert_conflict_diff_epoch_same_key_co_low_high_test.cpp +++ b/test/concurrency_control/long_tx/insert/long_insert_insert_conflict_diff_epoch_same_key_co_low_high_test.cpp @@ -85,6 +85,8 @@ TEST_F(long_insert_insert_conflict_diff_epoch_same_key_co_low_high_test, // NOLI _mm_pause(); } while (rc == Status::WARN_WAITING_FOR_OTHER_TX); ASSERT_EQ(Status::ERR_CC, rc); + //auto* ti = static_cast(s2); + //EXPECT_EQ(ti->get_result_info().get_reason_code(), reason_code::KVS_INSERT); ASSERT_EQ(Status::OK, leave(s1)); ASSERT_EQ(Status::OK, leave(s2)); }