From 378dcef813a3c87808a729bc388ca5ba7fff3fed Mon Sep 17 00:00:00 2001 From: Alexander Tokmakov Date: Tue, 27 Jul 2021 19:57:28 +0300 Subject: [PATCH] fixes --- src/Common/ZooKeeper/ZooKeeperImpl.cpp | 4 +- src/Interpreters/ZooKeeperLog.cpp | 14 ++-- src/Interpreters/ZooKeeperLog.h | 10 +-- .../0_stateless/01158_zookeeper_log.reference | 74 +++++++++---------- 4 files changed, 50 insertions(+), 52 deletions(-) diff --git a/src/Common/ZooKeeper/ZooKeeperImpl.cpp b/src/Common/ZooKeeper/ZooKeeperImpl.cpp index 05893d42fb6..bf67dccc684 100644 --- a/src/Common/ZooKeeper/ZooKeeperImpl.cpp +++ b/src/Common/ZooKeeper/ZooKeeperImpl.cpp @@ -1225,7 +1225,7 @@ void ZooKeeper::logOperationIfNeeded(const ZooKeeperRequestPtr & request, const if (request) { request->createLogElements(elems); - log_type = ZooKeeperLogElement::SEND; + log_type = ZooKeeperLogElement::REQUEST; } else { @@ -1237,7 +1237,7 @@ void ZooKeeper::logOperationIfNeeded(const ZooKeeperRequestPtr & request, const if (response) { response->fillLogElements(elems, 0); - log_type = ZooKeeperLogElement::RECEIVE; + log_type = ZooKeeperLogElement::RESPONSE; } if (finalize) diff --git a/src/Interpreters/ZooKeeperLog.cpp b/src/Interpreters/ZooKeeperLog.cpp index f2cbde668f7..bc187876d24 100644 --- a/src/Interpreters/ZooKeeperLog.cpp +++ b/src/Interpreters/ZooKeeperLog.cpp @@ -24,8 +24,8 @@ NamesAndTypesList ZooKeeperLogElement::getNamesAndTypes() auto type_enum = std::make_shared( DataTypeEnum8::Values { - {"Send", static_cast(SEND)}, - {"Receive", static_cast(RECEIVE)}, + {"Request", static_cast(REQUEST)}, + {"Response", static_cast(RESPONSE)}, {"Finalize", static_cast(FINALIZE)}, }); @@ -86,7 +86,6 @@ NamesAndTypesList ZooKeeperLogElement::getNamesAndTypes() auto watch_type_enum = std::make_shared( DataTypeEnum8::Values { - {"NONE", 0}, {"CREATED", static_cast(Coordination::Event::CREATED)}, {"DELETED", static_cast(Coordination::Event::DELETED)}, {"CHANGED", static_cast(Coordination::Event::CHANGED)}, @@ -98,7 +97,6 @@ NamesAndTypesList ZooKeeperLogElement::getNamesAndTypes() auto watch_state_enum = std::make_shared( DataTypeEnum16::Values { - {"NONE", 0}, {"EXPIRED_SESSION", static_cast(Coordination::State::EXPIRED_SESSION)}, {"AUTH_FAILED", static_cast(Coordination::State::AUTH_FAILED)}, {"CONNECTING", static_cast(Coordination::State::CONNECTING)}, @@ -134,8 +132,8 @@ NamesAndTypesList ZooKeeperLogElement::getNamesAndTypes() {"zxid", std::make_shared()}, {"error", std::make_shared(error_enum)}, - {"watch_type", watch_type_enum}, - {"watch_state", watch_state_enum}, + {"watch_type", std::make_shared(watch_type_enum)}, + {"watch_state", std::make_shared(watch_state_enum)}, {"path_created", std::make_shared()}, @@ -182,8 +180,8 @@ void ZooKeeperLogElement::appendToBlock(MutableColumns & columns) const columns[i++]->insert(zxid); columns[i++]->insert(error ? Field(*error) : Field()); - columns[i++]->insert(watch_type); - columns[i++]->insert(watch_state); + columns[i++]->insert(watch_type ? Field(*watch_type) : Field()); + columns[i++]->insert(watch_state ? Field(*watch_state) : Field()); columns[i++]->insert(path_created); diff --git a/src/Interpreters/ZooKeeperLog.h b/src/Interpreters/ZooKeeperLog.h index 9f8756d0691..d3ef68625af 100644 --- a/src/Interpreters/ZooKeeperLog.h +++ b/src/Interpreters/ZooKeeperLog.h @@ -14,8 +14,8 @@ struct ZooKeeperLogElement enum Type { UNKNOWN = 0, - SEND = 1, - RECEIVE = 2, + REQUEST = 1, + RESPONSE = 2, FINALIZE = 3 }; @@ -38,7 +38,7 @@ struct ZooKeeperLogElement bool is_sequential = false; /// remove, check, set - std::optional version = 0; + std::optional version; /// multi UInt32 requests_size = 0; @@ -49,8 +49,8 @@ struct ZooKeeperLogElement std::optional error; /// watch - Int32 watch_type = 0; - Int32 watch_state = 0; + std::optional watch_type; + std::optional watch_state; /// create String path_created; diff --git a/tests/queries/0_stateless/01158_zookeeper_log.reference b/tests/queries/0_stateless/01158_zookeeper_log.reference index 4caa9de5012..35a30ee04e3 100644 --- a/tests/queries/0_stateless/01158_zookeeper_log.reference +++ b/tests/queries/0_stateless/01158_zookeeper_log.reference @@ -1,40 +1,40 @@ log -Receive 0 Watch /test/01158/default/rmt/log 0 0 0 0 0 ZOK CHILD CONNECTED 0 0 0 0 -Send 0 Create /test/01158/default/rmt/log 0 0 0 0 4 \N NONE NONE 0 0 0 0 -Receive 0 Create /test/01158/default/rmt/log 0 0 0 0 4 ZOK NONE NONE /test/01158/default/rmt/log 0 0 0 0 -Send 0 Create /test/01158/default/rmt/log/log- 0 1 0 0 1 \N NONE NONE 0 0 0 0 -Receive 0 Create /test/01158/default/rmt/log/log- 0 1 0 0 1 ZOK NONE NONE /test/01158/default/rmt/log/log-0000000000 0 0 0 0 +Response 0 Watch /test/01158/default/rmt/log 0 0 \N 0 0 ZOK CHILD CONNECTED 0 0 0 0 +Request 0 Create /test/01158/default/rmt/log 0 0 \N 0 4 \N \N \N 0 0 0 0 +Response 0 Create /test/01158/default/rmt/log 0 0 \N 0 4 ZOK \N \N /test/01158/default/rmt/log 0 0 0 0 +Request 0 Create /test/01158/default/rmt/log/log- 0 1 \N 0 1 \N \N \N 0 0 0 0 +Response 0 Create /test/01158/default/rmt/log/log- 0 1 \N 0 1 ZOK \N \N /test/01158/default/rmt/log/log-0000000000 0 0 0 0 parts -Send 0 Multi 0 0 0 5 0 \N NONE NONE 0 0 0 0 -Send 0 Create /test/01158/default/rmt/log/log- 0 1 0 0 1 \N NONE NONE 0 0 0 0 -Send 0 Remove /test/01158/default/rmt/block_numbers/all/block-0000000000 0 0 -1 0 2 \N NONE NONE 0 0 0 0 -Send 0 Remove /test/01158/default/rmt/temp/abandonable_lock-0000000000 0 0 -1 0 3 \N NONE NONE 0 0 0 0 -Send 0 Create /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 4 \N NONE NONE 0 0 0 0 -Send 0 Create /test/01158/default/rmt/replicas/1/parts/all_0_0_0 0 0 0 0 5 \N NONE NONE 0 0 0 0 -Receive 0 Multi 0 0 0 5 0 ZOK NONE NONE 0 0 0 0 -Receive 0 Create /test/01158/default/rmt/log/log- 0 1 0 0 1 ZOK NONE NONE /test/01158/default/rmt/log/log-0000000000 0 0 0 0 -Receive 0 Remove /test/01158/default/rmt/block_numbers/all/block-0000000000 0 0 -1 0 2 ZOK NONE NONE 0 0 0 0 -Receive 0 Remove /test/01158/default/rmt/temp/abandonable_lock-0000000000 0 0 -1 0 3 ZOK NONE NONE 0 0 0 0 -Receive 0 Create /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 4 ZOK NONE NONE /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 -Receive 0 Create /test/01158/default/rmt/replicas/1/parts/all_0_0_0 0 0 0 0 5 ZOK NONE NONE /test/01158/default/rmt/replicas/1/parts/all_0_0_0 0 0 0 0 -Send 0 Exists /test/01158/default/rmt/replicas/1/parts/all_0_0_0 0 0 0 0 0 \N NONE NONE 0 0 0 0 -Receive 0 Exists /test/01158/default/rmt/replicas/1/parts/all_0_0_0 0 0 0 0 0 ZOK NONE NONE 0 0 96 0 +Request 0 Multi 0 0 \N 5 0 \N \N \N 0 0 0 0 +Request 0 Create /test/01158/default/rmt/log/log- 0 1 \N 0 1 \N \N \N 0 0 0 0 +Request 0 Remove /test/01158/default/rmt/block_numbers/all/block-0000000000 0 0 -1 0 2 \N \N \N 0 0 0 0 +Request 0 Remove /test/01158/default/rmt/temp/abandonable_lock-0000000000 0 0 -1 0 3 \N \N \N 0 0 0 0 +Request 0 Create /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 \N 0 4 \N \N \N 0 0 0 0 +Request 0 Create /test/01158/default/rmt/replicas/1/parts/all_0_0_0 0 0 \N 0 5 \N \N \N 0 0 0 0 +Response 0 Multi 0 0 \N 5 0 ZOK \N \N 0 0 0 0 +Response 0 Create /test/01158/default/rmt/log/log- 0 1 \N 0 1 ZOK \N \N /test/01158/default/rmt/log/log-0000000000 0 0 0 0 +Response 0 Remove /test/01158/default/rmt/block_numbers/all/block-0000000000 0 0 -1 0 2 ZOK \N \N 0 0 0 0 +Response 0 Remove /test/01158/default/rmt/temp/abandonable_lock-0000000000 0 0 -1 0 3 ZOK \N \N 0 0 0 0 +Response 0 Create /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 \N 0 4 ZOK \N \N /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 +Response 0 Create /test/01158/default/rmt/replicas/1/parts/all_0_0_0 0 0 \N 0 5 ZOK \N \N /test/01158/default/rmt/replicas/1/parts/all_0_0_0 0 0 0 0 +Request 0 Exists /test/01158/default/rmt/replicas/1/parts/all_0_0_0 0 0 \N 0 0 \N \N \N 0 0 0 0 +Response 0 Exists /test/01158/default/rmt/replicas/1/parts/all_0_0_0 0 0 \N 0 0 ZOK \N \N 0 0 96 0 blocks -Send 0 Multi 0 0 0 3 0 \N NONE NONE 0 0 0 0 -Send 0 Create /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 1 \N NONE NONE 0 0 0 0 -Send 0 Remove /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 -1 0 2 \N NONE NONE 0 0 0 0 -Send 0 Create /test/01158/default/rmt/temp/abandonable_lock- 1 1 0 0 3 \N NONE NONE 0 0 0 0 -Receive 0 Multi 0 0 0 3 0 ZOK NONE NONE 0 0 0 0 -Receive 0 Create /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 1 ZOK NONE NONE /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 -Receive 0 Remove /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 -1 0 2 ZOK NONE NONE 0 0 0 0 -Receive 0 Create /test/01158/default/rmt/temp/abandonable_lock- 1 1 0 0 3 ZOK NONE NONE /test/01158/default/rmt/temp/abandonable_lock-0000000000 0 0 0 0 -Send 0 Multi 0 0 0 3 0 \N NONE NONE 0 0 0 0 -Send 0 Create /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 1 \N NONE NONE 0 0 0 0 -Send 0 Remove /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 -1 0 2 \N NONE NONE 0 0 0 0 -Send 0 Create /test/01158/default/rmt/temp/abandonable_lock- 1 1 0 0 3 \N NONE NONE 0 0 0 0 -Receive 0 Multi 0 0 0 3 0 ZNODEEXISTS NONE NONE 0 0 0 0 -Receive 0 Error /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 1 ZNODEEXISTS NONE NONE 0 0 0 0 -Receive 0 Error /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 -1 0 2 ZRUNTIMEINCONSISTENCY NONE NONE 0 0 0 0 -Receive 0 Error /test/01158/default/rmt/temp/abandonable_lock- 1 1 0 0 3 ZRUNTIMEINCONSISTENCY NONE NONE 0 0 0 0 -Send 0 Get /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 0 \N NONE NONE 0 0 0 0 -Receive 0 Get /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 0 ZOK NONE NONE 0 0 9 0 +Request 0 Multi 0 0 \N 3 0 \N \N \N 0 0 0 0 +Request 0 Create /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 \N 0 1 \N \N \N 0 0 0 0 +Request 0 Remove /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 -1 0 2 \N \N \N 0 0 0 0 +Request 0 Create /test/01158/default/rmt/temp/abandonable_lock- 1 1 \N 0 3 \N \N \N 0 0 0 0 +Response 0 Multi 0 0 \N 3 0 ZOK \N \N 0 0 0 0 +Response 0 Create /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 \N 0 1 ZOK \N \N /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 0 0 +Response 0 Remove /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 -1 0 2 ZOK \N \N 0 0 0 0 +Response 0 Create /test/01158/default/rmt/temp/abandonable_lock- 1 1 \N 0 3 ZOK \N \N /test/01158/default/rmt/temp/abandonable_lock-0000000000 0 0 0 0 +Request 0 Multi 0 0 \N 3 0 \N \N \N 0 0 0 0 +Request 0 Create /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 \N 0 1 \N \N \N 0 0 0 0 +Request 0 Remove /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 -1 0 2 \N \N \N 0 0 0 0 +Request 0 Create /test/01158/default/rmt/temp/abandonable_lock- 1 1 \N 0 3 \N \N \N 0 0 0 0 +Response 0 Multi 0 0 \N 3 0 ZNODEEXISTS \N \N 0 0 0 0 +Response 0 Error /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 \N 0 1 ZNODEEXISTS \N \N 0 0 0 0 +Response 0 Error /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 -1 0 2 ZRUNTIMEINCONSISTENCY \N \N 0 0 0 0 +Response 0 Error /test/01158/default/rmt/temp/abandonable_lock- 1 1 \N 0 3 ZRUNTIMEINCONSISTENCY \N \N 0 0 0 0 +Request 0 Get /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 \N 0 0 \N \N \N 0 0 0 0 +Response 0 Get /test/01158/default/rmt/blocks/all_6308706741995381342_2495791770474910886 0 0 \N 0 0 ZOK \N \N 0 0 9 0