Merge pull request #13757 from ClickHouse/fix-flaky-test-3

Fix flaky test 01305_replica_create_drop_zookeeper
This commit is contained in:
alexey-milovidov 2020-08-16 10:15:30 +03:00 committed by GitHub
commit cd417bb066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -268,16 +268,28 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree(
{
bool is_first_replica = createTableIfNotExists(metadata_snapshot);
/// We have to check granularity on other replicas. If it's fixed we
/// must create our new replica with fixed granularity and store this
/// information in /replica/metadata.
other_replicas_fixed_granularity = checkFixedGranualrityInZookeeper();
try
{
/// NOTE If it's the first replica, these requests to ZooKeeper look redundant, we already know everything.
checkTableStructure(zookeeper_path, metadata_snapshot);
/// We have to check granularity on other replicas. If it's fixed we
/// must create our new replica with fixed granularity and store this
/// information in /replica/metadata.
other_replicas_fixed_granularity = checkFixedGranualrityInZookeeper();
Coordination::Stat metadata_stat;
current_zookeeper->get(zookeeper_path + "/metadata", &metadata_stat);
metadata_version = metadata_stat.version;
checkTableStructure(zookeeper_path, metadata_snapshot);
Coordination::Stat metadata_stat;
current_zookeeper->get(zookeeper_path + "/metadata", &metadata_stat);
metadata_version = metadata_stat.version;
}
catch (Coordination::Exception & e)
{
if (!is_first_replica && e.code == Coordination::Error::ZNONODE)
throw Exception("Table " + zookeeper_path + " was suddenly removed.", ErrorCodes::ALL_REPLICAS_LOST);
else
throw;
}
if (!is_first_replica)
createReplica(metadata_snapshot);
@ -291,7 +303,6 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree(
}
else
{
/// In old tables this node may missing or be empty
String replica_metadata;
bool replica_metadata_exists = current_zookeeper->tryGet(replica_path + "/metadata", replica_metadata);
@ -758,9 +769,9 @@ void StorageReplicatedMergeTree::dropReplica(zkutil::ZooKeeperPtr zookeeper, con
}
/** Verify that list of columns and table storage_settings_ptr match those specified in ZK (/ metadata).
* If not, throw an exception.
*/
/** Verify that list of columns and table storage_settings_ptr match those specified in ZK (/metadata).
* If not, throw an exception.
*/
void StorageReplicatedMergeTree::checkTableStructure(const String & zookeeper_prefix, const StorageMetadataPtr & metadata_snapshot)
{
auto zookeeper = getZooKeeper();