mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Fix KeeperMap create after incomplete drop
This commit is contained in:
parent
5547ce1a91
commit
c36dde5103
@ -57,7 +57,8 @@ static struct InitFiu
|
||||
PAUSEABLE_ONCE(finish_clean_quorum_failed_parts) \
|
||||
PAUSEABLE(dummy_pausable_failpoint) \
|
||||
ONCE(execute_query_calling_empty_set_result_func_on_exception) \
|
||||
ONCE(receive_timeout_on_table_status_response)
|
||||
ONCE(receive_timeout_on_table_status_response) \
|
||||
ONCE(keepermap_fail_drop_data) \
|
||||
|
||||
|
||||
namespace FailPoints
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include <Common/Base64.h>
|
||||
#include <Common/Exception.h>
|
||||
#include <Common/FailPoint.h>
|
||||
#include <Common/ZooKeeper/IKeeper.h>
|
||||
#include <Common/ZooKeeper/KeeperException.h>
|
||||
#include <Common/ZooKeeper/Types.h>
|
||||
@ -64,6 +65,11 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace FailPoints
|
||||
{
|
||||
extern const char keepermap_fail_drop_data[];
|
||||
}
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
||||
@ -411,18 +417,13 @@ StorageKeeperMap::StorageKeeperMap(
|
||||
|
||||
auto code = client->tryCreate(zk_table_path, "", zkutil::CreateMode::Persistent);
|
||||
|
||||
// tables_path was removed with drop
|
||||
if (code == Coordination::Error::ZNONODE)
|
||||
{
|
||||
LOG_INFO(log, "Metadata nodes were removed by another server, will retry");
|
||||
continue;
|
||||
}
|
||||
else if (code != Coordination::Error::ZOK)
|
||||
{
|
||||
throw zkutil::KeeperException(code, "Failed to create table on path {} because a table with same UUID already exists", zk_root_path);
|
||||
}
|
||||
|
||||
if (code == Coordination::Error::ZOK)
|
||||
return;
|
||||
|
||||
if (code != Coordination::Error::ZNONODE)
|
||||
throw zkutil::KeeperException(code, "Failed to create table on path {} because a table with same UUID already exists", zk_root_path);
|
||||
|
||||
/// ZNONODE means we dropped zk_tables_path but didn't finish drop completely
|
||||
}
|
||||
|
||||
if (client->exists(zk_dropped_path))
|
||||
@ -561,6 +562,10 @@ void StorageKeeperMap::truncate(const ASTPtr &, const StorageMetadataPtr &, Cont
|
||||
|
||||
bool StorageKeeperMap::dropTable(zkutil::ZooKeeperPtr zookeeper, const zkutil::EphemeralNodeHolder::Ptr & metadata_drop_lock)
|
||||
{
|
||||
fiu_do_on(FailPoints::keepermap_fail_drop_data,
|
||||
{
|
||||
throw zkutil::KeeperException(Coordination::Error::ZOPERATIONTIMEOUT, "Manually triggered operation timeout");
|
||||
});
|
||||
zookeeper->removeChildrenRecursive(zk_data_path);
|
||||
|
||||
bool completely_removed = false;
|
||||
|
@ -0,0 +1,7 @@
|
||||
DROP TABLE IF EXISTS 03208_keepermap_test SYNC;
|
||||
|
||||
CREATE TABLE 03208_keepermap_test (key UInt64, value UInt64) Engine=KeeperMap('/' || currentDatabase() || '/test03208') PRIMARY KEY(key);
|
||||
INSERT INTO 03208_keepermap_test VALUES (1, 11);
|
||||
SYSTEM ENABLE FAILPOINT keepermap_fail_drop_data;
|
||||
DROP TABLE 03208_keepermap_test;
|
||||
CREATE TABLE 03208_keepermap_test_another (key UInt64, value UInt64) Engine=KeeperMap('/' || currentDatabase() || '/test03208') PRIMARY KEY(key);
|
Loading…
Reference in New Issue
Block a user