ReplicatedMergeTree - cleanup data directory after Zookeeper exceptions#14563
Merged
tavplubix merged 9 commits intoClickHouse:masterfrom Sep 10, 2020
bharatnc:ncb/zk-conn-fail-do-cleanup
Merged
ReplicatedMergeTree - cleanup data directory after Zookeeper exceptions#14563tavplubix merged 9 commits intoClickHouse:masterfrom bharatnc:ncb/zk-conn-fail-do-cleanup
tavplubix merged 9 commits intoClickHouse:masterfrom
bharatnc:ncb/zk-conn-fail-do-cleanup
Conversation
It's possible for `getZooKeeper()` to timeout if zookeeper host(s) can't be reached. In such cases `Poco::Exception` is thrown after a connection timeout - refer to `src/Common/ZooKeeper/ZooKeeperImpl.cpp:866` for more info. Side effect of this is that the CreateQuery gets interrupted and it exits. But the data Directories for the tables being created aren't cleaned up. This unclean state will hinder table creation on any retries and will complain that the Directory for table already exists. To achieve a clean state on failed table creations, catch this error if the exception is of type Poco::Exception and call `dropIfEmpty()` method, then proceed throwing the exception. Without this, the Directory for the tables need to be manually deleted before retrying the CreateQuery.
bharatnc
commented
Sep 8, 2020
This adds a integration test that tests if table directory is cleaned up after a ZooKeeper connection failure for ReplicatedMergeTree tables.
Contributor
Author
|
Also addresses #14115 |
tavplubix
approved these changes
Sep 9, 2020
Contributor
Author
|
@tavplubix thank you for adding those tests. Should this PR be considered a |
filimonov
reviewed
Sep 10, 2020
Member
Ok, let's change the changelog category to "Bug Fix", so it will be backported |
This was referenced Sep 10, 2020
robot-clickhouse
pushed a commit
that referenced
this pull request
Sep 10, 2020
… after Zookeeper exceptions
robot-clickhouse
pushed a commit
that referenced
this pull request
Sep 10, 2020
… after Zookeeper exceptions
robot-clickhouse
pushed a commit
that referenced
this pull request
Sep 10, 2020
… after Zookeeper exceptions
robot-clickhouse
pushed a commit
that referenced
this pull request
Sep 10, 2020
… after Zookeeper exceptions
tavplubix
added a commit
that referenced
this pull request
Sep 11, 2020
Backport #14563 to 20.6: ReplicatedMergeTree - cleanup data directory after Zookeeper exceptions
tavplubix
added a commit
that referenced
this pull request
Sep 11, 2020
Backport #14563 to 20.8: ReplicatedMergeTree - cleanup data directory after Zookeeper exceptions
tavplubix
added a commit
that referenced
this pull request
Sep 11, 2020
Backport #14563 to 20.9: ReplicatedMergeTree - cleanup data directory after Zookeeper exceptions
tavplubix
added a commit
that referenced
this pull request
Sep 11, 2020
Backport #14563 to 20.7: ReplicatedMergeTree - cleanup data directory after Zookeeper exceptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Cleanup data directory after Zookeeper exceptions during CreateQuery for StorageReplicatedMergeTree Engine.
Detailed description / Documentation draft:
It's possible for
getZooKeeper()to timeout if zookeeper host(s) can'tbe reached. In such cases
Poco::Exceptionis thrown after a connectiontimeout - refer to
src/Common/ZooKeeper/ZooKeeperImpl.cpp:866for more info.Side effect of this is that the CreateQuery gets interrupted and it exits.
But the data Directories for the tables being created aren't cleaned up.
This unclean state will hinder table creation on any retries and will
complain that the Directory for table already exists.
To achieve a clean state on failed table creations, catch this error if
the exception is of type Poco::Exception and call
dropIfEmpty()method,then proceed throwing the exception. Without this, the Directory for the
tables need to be manually deleted before retrying the CreateQuery.
This addresses: #14517