Skip to content

fix(transaction): Fix schedule queues #4925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/server/list_family_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1326,14 +1326,14 @@ TEST_F(ListFamilyTest, LMPopWrongType) {
// Reproduce a flow that trigerred a wrong DCHECK in the transaction flow.
TEST_F(ListFamilyTest, AwakeMulti) {
auto f1 = pp_->at(1)->LaunchFiber(Launch::dispatch, [&] {
for (unsigned i = 0; i < 100; ++i) {
for (unsigned i = 0; i < 200; ++i) {
Run("CONSUMER", {"blmove", "src", "dest", "LEFT", "LEFT", "0"});
};
});
auto f2 = pp_->at(1)->LaunchFiber([&] {
for (unsigned i = 0; i < 100; ++i) {
for (unsigned i = 0; i < 200; ++i) {
Run("PROD", {"lpush", "src", "a"});
ThisFiber::SleepFor(50us);
ThisFiber::SleepFor(10us);
};
});

Expand Down
8 changes: 2 additions & 6 deletions src/server/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -759,11 +759,7 @@ void Transaction::ScheduleInternal() {

ScheduleContext schedule_ctx{this, optimistic_exec};

// TODO: this optimization is disabled due to a issue #4648 revealing this code can
// lead to transaction not being scheduled.
// To reproduce the bug remove the false in the condition and run
// ./list_family_test --gtest_filter=*AwakeMulti on alpine machine
if (false && unique_shard_cnt_ == 1) {
if (unique_shard_cnt_ == 1) {
// Single shard optimization. Note: we could apply the same optimization
// to multi-shard transactions as well by creating a vector of ScheduleContext.
schedule_queues[unique_shard_id_].queue.Push(&schedule_ctx);
Expand Down Expand Up @@ -1212,7 +1208,7 @@ void Transaction::ScheduleBatchInShard() {
// We do this to avoid the situation where we have a data race, where
// a transaction is added to the queue, we've checked that sq.armed is true and skipped
// adding the callback that fetches the transaction.
sq.armed.store(false, memory_order_release);
sq.armed.exchange(false, memory_order_acq_rel);
}
}

Expand Down
Loading