mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 21:24:28 +00:00
Small fixes
This commit is contained in:
parent
188a88fa33
commit
5fea9f9dc6
@ -135,6 +135,16 @@ struct MultiReadResponses
|
||||
responses);
|
||||
}
|
||||
|
||||
/// If Keeper/ZooKeeper doesn't support MultiRead feature we will dispatch
|
||||
/// asynchronously all the read requests separately
|
||||
/// Sometimes it's important to process all requests instantly
|
||||
/// e.g. we want to trigger exceptions while we are in the ZK client retry loop
|
||||
void waitForResponses()
|
||||
{
|
||||
if (auto * responses_with_futures = std::get_if<ResponsesWithFutures>(&responses))
|
||||
responses_with_futures->waitForResponses();
|
||||
}
|
||||
|
||||
private:
|
||||
using RegularResponses = std::vector<Coordination::ResponsePtr>;
|
||||
using FutureResponses = std::vector<std::future<ResponseType>>;
|
||||
@ -158,6 +168,15 @@ private:
|
||||
return *cached_responses[index];
|
||||
}
|
||||
|
||||
void waitForResponses()
|
||||
{
|
||||
for (size_t i = 0; i < size(); ++i)
|
||||
{
|
||||
if (!cached_responses[i].has_value())
|
||||
cached_responses[i] = future_responses[i].get();
|
||||
}
|
||||
}
|
||||
|
||||
size_t size() const { return future_responses.size(); }
|
||||
};
|
||||
|
||||
|
@ -242,6 +242,11 @@ public:
|
||||
return access("get", !paths.empty() ? paths.front() : "", [&]() { return keeper->get(paths); });
|
||||
}
|
||||
|
||||
zkutil::ZooKeeper::MultiTryGetResponse tryGet(const std::vector<std::string> & paths)
|
||||
{
|
||||
return access("tryGet", !paths.empty() ? paths.front() : "", [&]() { return keeper->tryGet(paths); });
|
||||
}
|
||||
|
||||
bool exists(const std::string & path, Coordination::Stat * stat = nullptr, const zkutil::EventPtr & watch = nullptr)
|
||||
{
|
||||
return access("exists", path, [&]() { return keeper->exists(path, stat, watch); });
|
||||
|
@ -703,13 +703,14 @@ private:
|
||||
for (const auto & key : keys)
|
||||
keys_full_path.push_back(data_zookeeper_path / key);
|
||||
|
||||
zkutil::ZooKeeper::MultiGetResponse data;
|
||||
zkutil::ZooKeeper::MultiTryGetResponse data;
|
||||
auto holder = with_retries->createRetriesControlHolder("getKeeperMapDataKeys");
|
||||
holder.retries_ctl.retryLoop(
|
||||
[&, &zk = holder.faulty_zookeeper]
|
||||
{
|
||||
with_retries->renewZooKeeper(zk);
|
||||
data = zk->get(keys_full_path);
|
||||
data = zk->tryGet(keys_full_path);
|
||||
data.waitForResponses();
|
||||
});
|
||||
|
||||
for (size_t i = 0; i < keys.size(); ++i)
|
||||
|
@ -4,44 +4,45 @@ CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CUR_DIR"/../shell_config.sh
|
||||
|
||||
database_name="$CLICKHOUSE_DATABASE"_02911_keeper_map
|
||||
$CLICKHOUSE_CLIENT -nm -q "
|
||||
DROP DATABASE IF EXISTS 02911_keeper_map;
|
||||
CREATE DATABASE 02911_keeper_map;
|
||||
CREATE TABLE 02911_keeper_map.02911_backup_restore_keeper_map1 (key UInt64, value String) Engine=KeeperMap('/' || currentDatabase() || '/test02911') PRIMARY KEY key;
|
||||
CREATE TABLE 02911_keeper_map.02911_backup_restore_keeper_map2 (key UInt64, value String) Engine=KeeperMap('/' || currentDatabase() || '/test02911') PRIMARY KEY key;
|
||||
CREATE TABLE 02911_keeper_map.02911_backup_restore_keeper_map3 (key UInt64, value String) Engine=KeeperMap('/' || currentDatabase() || '/test02911_different') PRIMARY KEY key;
|
||||
DROP DATABASE IF EXISTS $database_name;
|
||||
CREATE DATABASE $database_name;
|
||||
CREATE TABLE $database_name.02911_backup_restore_keeper_map1 (key UInt64, value String) Engine=KeeperMap('/' || currentDatabase() || '/test02911') PRIMARY KEY key;
|
||||
CREATE TABLE $database_name.02911_backup_restore_keeper_map2 (key UInt64, value String) Engine=KeeperMap('/' || currentDatabase() || '/test02911') PRIMARY KEY key;
|
||||
CREATE TABLE $database_name.02911_backup_restore_keeper_map3 (key UInt64, value String) Engine=KeeperMap('/' || currentDatabase() || '/test02911_different') PRIMARY KEY key;
|
||||
|
||||
INSERT INTO 02911_keeper_map.02911_backup_restore_keeper_map2 SELECT number, 'test' || toString(number) FROM system.numbers LIMIT 5000;
|
||||
INSERT INTO 02911_keeper_map.02911_backup_restore_keeper_map3 SELECT number, 'test' || toString(number) FROM system.numbers LIMIT 3000;
|
||||
INSERT INTO $database_name.02911_backup_restore_keeper_map2 SELECT number, 'test' || toString(number) FROM system.numbers LIMIT 5000;
|
||||
INSERT INTO $database_name.02911_backup_restore_keeper_map3 SELECT number, 'test' || toString(number) FROM system.numbers LIMIT 3000;
|
||||
"
|
||||
|
||||
backup_path="$CLICKHOUSE_DATABASE/02911_keeper_map"
|
||||
backup_path="$database_name"
|
||||
for i in $(seq 1 3); do
|
||||
$CLICKHOUSE_CLIENT -q "SELECT count() FROM 02911_keeper_map.02911_backup_restore_keeper_map$i;"
|
||||
$CLICKHOUSE_CLIENT -q "SELECT count() FROM $database_name.02911_backup_restore_keeper_map$i;"
|
||||
done
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "BACKUP DATABASE 02911_keeper_map TO Disk('backups', '$backup_path');" > /dev/null
|
||||
$CLICKHOUSE_CLIENT -q "BACKUP DATABASE $database_name TO Disk('backups', '$backup_path');" > /dev/null
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "DROP DATABASE 02911_keeper_map SYNC;"
|
||||
$CLICKHOUSE_CLIENT -q "DROP DATABASE $database_name SYNC;"
|
||||
|
||||
for i in $(seq 1 3); do
|
||||
$CLICKHOUSE_CLIENT -q "SELECT count() FROM 02911_keeper_map.02911_backup_restore_keeper_map$i;" 2>&1 | grep -Fq "UNKNOWN_DATABASE" && echo 'OK' || echo 'ERROR'
|
||||
$CLICKHOUSE_CLIENT -q "SELECT count() FROM $database_name.02911_backup_restore_keeper_map$i;" 2>&1 | grep -Fq "UNKNOWN_DATABASE" && echo 'OK' || echo 'ERROR'
|
||||
done
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "RESTORE DATABASE 02911_keeper_map FROM Disk('backups', '$backup_path');" > /dev/null
|
||||
$CLICKHOUSE_CLIENT -q "RESTORE DATABASE $database_name FROM Disk('backups', '$backup_path');" > /dev/null
|
||||
|
||||
for i in $(seq 1 3); do
|
||||
$CLICKHOUSE_CLIENT -q "SELECT count() FROM 02911_keeper_map.02911_backup_restore_keeper_map$i;"
|
||||
$CLICKHOUSE_CLIENT -q "SELECT count() FROM $database_name.02911_backup_restore_keeper_map$i;"
|
||||
done
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "DROP TABLE 02911_keeper_map.02911_backup_restore_keeper_map3 SYNC;"
|
||||
$CLICKHOUSE_CLIENT -q "DROP TABLE $database_name.02911_backup_restore_keeper_map3 SYNC;"
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "SELECT count() FROM 02911_keeper_map.02911_backup_restore_keeper_map3;" 2>&1 | grep -Fq "UNKNOWN_TABLE" && echo 'OK' || echo 'ERROR'
|
||||
$CLICKHOUSE_CLIENT -q "SELECT count() FROM $database_name.02911_backup_restore_keeper_map3;" 2>&1 | grep -Fq "UNKNOWN_TABLE" && echo 'OK' || echo 'ERROR'
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "RESTORE TABLE 02911_keeper_map.02911_backup_restore_keeper_map3 FROM Disk('backups', '$backup_path');" > /dev/null
|
||||
$CLICKHOUSE_CLIENT -q "RESTORE TABLE $database_name.02911_backup_restore_keeper_map3 FROM Disk('backups', '$backup_path');" > /dev/null
|
||||
|
||||
for i in $(seq 1 3); do
|
||||
$CLICKHOUSE_CLIENT -q "SELECT count() FROM 02911_keeper_map.02911_backup_restore_keeper_map$i;"
|
||||
$CLICKHOUSE_CLIENT -q "SELECT count() FROM $database_name.02911_backup_restore_keeper_map$i;"
|
||||
done
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "DROP DATABASE 02911_keeper_map SYNC;"
|
||||
$CLICKHOUSE_CLIENT -q "DROP DATABASE $database_name SYNC;"
|
Loading…
Reference in New Issue
Block a user