Skip to content
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

fix(server): Fix transaction bug #787

Merged
merged 1 commit into from
Feb 13, 2023
Merged
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
11 changes: 9 additions & 2 deletions src/server/dragonfly_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ class DflyEngineTest : public BaseFamilyTest {
}
};

class DefragDflyEngineTest : public BaseFamilyTest {
class SingleThreadDflyEngineTest : public BaseFamilyTest {
protected:
DefragDflyEngineTest() : BaseFamilyTest() {
SingleThreadDflyEngineTest() : BaseFamilyTest() {
num_threads_ = 1;
}
};

class DefragDflyEngineTest : public SingleThreadDflyEngineTest {};

// TODO: to implement equivalent parsing in redis parser.
TEST_F(DflyEngineTest, Sds) {
int argc;
Expand Down Expand Up @@ -92,6 +94,11 @@ TEST_F(DflyEngineTest, Sds) {
sdsfreesplitres(argv, argc);
}

TEST_F(SingleThreadDflyEngineTest, GlobalSingleThread) {
Run({"set", "a", "1"});
Run({"move", "a", "1"});
}

TEST_F(DflyEngineTest, MultiAndEval) {
ShardId sid1 = Shard(kKey1, num_threads_ - 1);
ShardId sid2 = Shard(kKey2, num_threads_ - 1);
Expand Down
2 changes: 1 addition & 1 deletion src/server/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class Transaction {
// Iterate over shards and run function accepting (PerShardData&, ShardId) on all active ones.
template <typename F> void IterateActiveShards(F&& f) {
bool is_global = IsGlobal();
if (unique_shard_cnt_ == 1) {
if (!is_global && unique_shard_cnt_ == 1) { // unique_shard_id_ is set only for non-global.
auto i = unique_shard_id_;
f(shard_data_[SidToId(i)], i);
} else {
Expand Down