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: fix multi mget exec error message #3662

Merged
merged 1 commit into from
Sep 6, 2024
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
8 changes: 4 additions & 4 deletions src/server/main_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2187,6 +2187,10 @@ void Service::Exec(CmdArgList args, ConnectionContext* cntx) {
// Clean the context no matter the outcome
absl::Cleanup exec_clear = [&cntx] { MultiCleanup(cntx); };

if (exec_info.state == ConnectionState::ExecInfo::EXEC_ERROR) {
return cntx->SendError("-EXECABORT Transaction discarded because of previous errors");
}

// Check basic invariants
if (!exec_info.IsCollecting()) {
return cntx->SendError("EXEC without MULTI");
Expand All @@ -2196,10 +2200,6 @@ void Service::Exec(CmdArgList args, ConnectionContext* cntx) {
return cntx->SendError("Dragonfly does not allow WATCH and EXEC on different databases");
}

if (exec_info.state == ConnectionState::ExecInfo::EXEC_ERROR) {
return cntx->SendError("-EXECABORT Transaction discarded because of previous errors");
}

if (exec_info.watched_dirty.load(memory_order_relaxed)) {
return rb->SendNull();
}
Expand Down
3 changes: 2 additions & 1 deletion src/server/multi_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ TEST_F(MultiTest, MultiAndFlush) {
}

TEST_F(MultiTest, MultiWithError) {
EXPECT_THAT(Run({"exec"}), ErrArg("EXEC without MULTI"));
EXPECT_THAT(Run({"multi"}), "OK");
EXPECT_THAT(Run({"set", "x", "y"}), "QUEUED");
EXPECT_THAT(Run({"set", "x"}), ErrArg("wrong number of arguments for 'set' command"));
EXPECT_THAT(Run({"exec"}), ErrArg("EXEC without MULTI"));
EXPECT_THAT(Run({"exec"}), ErrArg("EXECABORT Transaction discarded because of previous errors"));

EXPECT_THAT(Run({"multi"}), "OK");
EXPECT_THAT(Run({"set", "z", "y"}), "QUEUED");
Expand Down
Loading