fix: fix multi mget exec error message (#3662)

This commit is contained in:
Borys 2024-09-06 13:06:02 +03:00 committed by GitHub
parent 2cc2a23247
commit 894bf4735b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View file

@ -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");
@ -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();
}

View file

@ -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");