More correct initialization

This commit is contained in:
alesapin 2020-11-20 11:37:16 +03:00
parent fdf3b569f4
commit 73ed05492b
3 changed files with 8 additions and 4 deletions

View File

@ -40,6 +40,7 @@ static void processWatchesImpl(const String & path, TestKeeperStorage::Watches &
Coordination::ZooKeeperWatchResponse watch_response;
watch_response.path = path;
watch_response.xid = -1;
watch_response.zxid = -1;
auto it = watches.find(watch_response.path);
if (it != watches.end())
@ -54,6 +55,7 @@ static void processWatchesImpl(const String & path, TestKeeperStorage::Watches &
Coordination::ZooKeeperWatchResponse watch_list_response;
watch_list_response.path = parentPath(path);
watch_list_response.xid = -1;
watch_list_response.zxid = -1;
it = list_watches.find(watch_list_response.path);
if (it != list_watches.end())
@ -238,7 +240,7 @@ struct TestKeeperStorageRemoveRequest final : public TestKeeperStorageRequest
else
{
auto prev_node = it->second;
if (it->second.is_ephemeral)
if (prev_node.is_ephemeral)
ephemerals[session_id].erase(request.path);
container.erase(it);
@ -247,8 +249,11 @@ struct TestKeeperStorageRemoveRequest final : public TestKeeperStorageRequest
++parent.stat.cversion;
response.error = Coordination::Error::ZOK;
undo = [prev_node, &container, path = request.path]
undo = [prev_node, &container, &ephemerals, session_id, path = request.path]
{
if (prev_node.is_ephemeral)
ephemerals[session_id].emplace(path);
container.emplace(path, prev_node);
auto & undo_parent = container.at(parentPath(path));
++undo_parent.stat.numChildren;

View File

@ -17,12 +17,10 @@ namespace DB
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
void TestKeeperTCPHandler::sendHandshake()
{
session_id = test_keeper_storage->getSessionID();
Coordination::write(Coordination::SERVER_HANDSHAKE_LENGTH, *out);
Coordination::write(Coordination::ZOOKEEPER_PROTOCOL_VERSION, *out);
Coordination::write(Coordination::DEFAULT_SESSION_TIMEOUT_MS, *out);

View File

@ -25,6 +25,7 @@ public:
, test_keeper_storage(global_context.getTestKeeperStorage())
, operation_timeout(0, Coordination::DEFAULT_OPERATION_TIMEOUT_MS * 1000)
, session_timeout(0, Coordination::DEFAULT_SESSION_TIMEOUT_MS * 1000)
, session_id(test_keeper_storage->getSessionID())
{
}