Skip to content

Commit

Permalink
fix test, add nolint and fix bug about bg commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thawk105 committed Aug 17, 2023
1 parent 8596d09 commit bd3a3d7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
18 changes: 8 additions & 10 deletions src/concurrency_control/bg_work/bg_commit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ void bg_commit::worker() {
REFIND : // NOLINT
{
std::shared_lock<std::shared_mutex> lk1{mtx_cont_wait_tx()};
// if cont empty then clear used_ids
if (cont_wait_tx().empty()) {
{
std::unique_lock<std::mutex> 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);
Expand Down Expand Up @@ -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<std::mutex> lk2{mtx_used_ids()};
used_ids().erase(tx_id);
}
goto REFIND; // NOLINT
} // termination was successed
ti->set_result_requested_commit(rc);
Expand All @@ -138,11 +141,6 @@ void bg_commit::worker() {
{
std::lock_guard<std::shared_mutex> lk1{mtx_cont_wait_tx()};
cont_wait_tx().erase(std::make_tuple(tx_id, token));
// erase from used_ids
{
std::unique_lock<std::mutex> lk2{mtx_used_ids()};
used_ids().erase(tx_id);
}
}

goto REFIND; // NOLINT
Expand Down
2 changes: 1 addition & 1 deletion src/concurrency_control/include/tid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/concurrency_control/ongoing_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Storage> st_set{};
// create and compaction about storage set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<session*>(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));
}
Expand Down

0 comments on commit bd3a3d7

Please sign in to comment.