Move queue initialization to restarting thread

This commit is contained in:
alesapin 2021-09-13 11:00:07 +03:00
parent 91e10adca5
commit ab41384f63
3 changed files with 7 additions and 2 deletions

View File

@ -59,6 +59,11 @@ void ReplicatedMergeTreeQueue::initialize(zkutil::ZooKeeperPtr zookeeper)
{
std::lock_guard lock(state_mutex);
/// Clear parts before setting new one
current_parts.clear();
virtual_parts.clear();
/// Get current parts state from zookeeper
Strings parts = zookeeper->getChildren(replica_path + "/parts");
for (const auto & part_name : parts)
{

View File

@ -174,6 +174,8 @@ bool ReplicatedMergeTreeRestartingThread::tryStartup()
try
{
storage.queue.initialize(zookeeper);
storage.queue.load(zookeeper);
/// pullLogsToQueue() after we mark replica 'is_active' (and after we repair if it was lost);

View File

@ -4285,8 +4285,6 @@ void StorageReplicatedMergeTree::startup()
try
{
queue.initialize(getZooKeeper());
InterserverIOEndpointPtr data_parts_exchange_ptr = std::make_shared<DataPartsExchange::Service>(*this);
[[maybe_unused]] auto prev_ptr = std::atomic_exchange(&data_parts_exchange_endpoint, data_parts_exchange_ptr);
assert(prev_ptr == nullptr);