Remove parts from mutations on replica start

This commit is contained in:
alesapin 2020-02-18 22:57:48 +03:00
parent 1f4b42a99f
commit f4b2be7b32
3 changed files with 8 additions and 3 deletions

View File

@ -205,9 +205,6 @@ void ReplicatedMergeTreeQueue::updateStateOnQueueEntryRemoval(
for (const String & virtual_part_name : entry->getVirtualPartNames()) for (const String & virtual_part_name : entry->getVirtualPartNames())
{ {
Strings replaced_parts; Strings replaced_parts;
/// In most cases we will replace only current parts, but sometimes
/// we can even replace virtual parts. For example when we failed to
/// GET source part and dowloaded merged/mutated part instead.
current_parts.add(virtual_part_name, &replaced_parts); current_parts.add(virtual_part_name, &replaced_parts);
/// Each part from `replaced_parts` should become Obsolete as a result of executing the entry. /// Each part from `replaced_parts` should become Obsolete as a result of executing the entry.
@ -1896,4 +1893,10 @@ String padIndex(Int64 index)
return std::string(10 - index_str.size(), '0') + index_str; return std::string(10 - index_str.size(), '0') + index_str;
} }
void ReplicatedMergeTreeQueue::removeCurrentPartsFromMutations()
{
std::lock_guard state_lock(state_mutex);
for (const auto & part_name : current_parts.getParts())
removePartFromMutations(part_name);
}
} }

View File

@ -383,6 +383,7 @@ public:
std::vector<MergeTreeMutationStatus> getMutationsStatus() const; std::vector<MergeTreeMutationStatus> getMutationsStatus() const;
void removeCurrentPartsFromMutations();
}; };
class ReplicatedMergeTreeMergePredicate class ReplicatedMergeTreeMergePredicate

View File

@ -180,6 +180,7 @@ bool ReplicatedMergeTreeRestartingThread::tryStartup()
/// pullLogsToQueue() after we mark replica 'is_active' (and after we repair if it was lost); /// pullLogsToQueue() after we mark replica 'is_active' (and after we repair if it was lost);
/// because cleanup_thread doesn't delete log_pointer of active replicas. /// because cleanup_thread doesn't delete log_pointer of active replicas.
storage.queue.pullLogsToQueue(zookeeper); storage.queue.pullLogsToQueue(zookeeper);
storage.queue.removeCurrentPartsFromMutations();
storage.last_queue_update_finish_time.store(time(nullptr)); storage.last_queue_update_finish_time.store(time(nullptr));
updateQuorumIfWeHavePart(); updateQuorumIfWeHavePart();