Commit 6f26619e authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Prevent cluster from crashing when a read-only MULTI follows a read-write one

parent 3c1ee3e2
Pipeline #521073 passed with stages
in 28 minutes
......@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
## Unreleased
- Updated rocksdb dependency to v5.15.10.
- Added `TYPE` command.
- A read-only MULTI immediatelly after a read-write MULTI could
cause the cluster to crash.
## 0.3.3 (2018-09-14)
......
......@@ -131,6 +131,8 @@ bool Transaction::deserialize(const std::string &src) {
void Transaction::clear() {
requests.clear();
phantom = false;
hasWrites = false;
}
std::string Transaction::getFusedCommand() const {
......
......@@ -122,6 +122,25 @@ TEST_F(Multi, HandlerBasicSanity) {
replies.clear();
ASSERT_REPLY(tunnel(leaderID)->exec("EXEC"), "ERR EXEC without MULTI");
ASSERT_REPLY(tunnel(leaderID)->exec("HGET", "myhash", "f1"), "v1");
// Read MULTI-EXEC right after a write
replies.clear();
replies.push_back(tunnel(leaderID)->exec("MULTI"));
replies.push_back(tunnel(leaderID)->exec("SET", "abc", "123"));
replies.push_back(tunnel(leaderID)->exec("EXEC"));
ASSERT_REPLY(replies[0], "OK");
ASSERT_REPLY(replies[1], "QUEUED");
ASSERT_REPLY_DESCRIBE(replies[2], "1) OK\n");
replies.clear();
replies.push_back(tunnel(leaderID)->exec("MULTI"));
replies.push_back(tunnel(leaderID)->exec("GET", "abc"));
replies.push_back(tunnel(leaderID)->exec("EXEC"));
ASSERT_REPLY(replies[0], "OK");
ASSERT_REPLY(replies[1], "QUEUED");
ASSERT_REPLY_DESCRIBE(replies[2], "1) \"123\"\n");
}
TEST_F(Multi, WithRaft) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment