File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -1620,6 +1620,16 @@ void DatabaseReplicated::recoverLostReplica(const ZooKeeperPtr & current_zookeep
16201620 // / It's a very rare case, and it's okay if some queries throw TIMEOUT_EXCEEDED when waiting for all replicas
16211621 if (first_entry_to_mark_finished)
16221622 {
1623+ // / Skip non-existing entries that were removed a long time ago (if the replica was offline for a long time)
1624+ Strings all_nodes = current_zookeeper->getChildren (fs::path (zookeeper_path) / " log" );
1625+ std::erase_if (all_nodes, [] (const String & s) { return !startsWith (s, " query-" ); });
1626+ auto oldest_node = std::min_element (all_nodes.begin (), all_nodes.end ());
1627+ if (oldest_node != all_nodes.end ())
1628+ {
1629+ UInt32 oldest_entry = DDLTaskBase::getLogEntryNumber (*oldest_node);
1630+ first_entry_to_mark_finished = std::max (oldest_entry, first_entry_to_mark_finished);
1631+ }
1632+
16231633 // / If the replica is new and some of the queries applied during recovery
16241634 // / where issued after the replica was created, then other nodes might be
16251635 // / waiting for this node to notify them that the query was applied.
You can’t perform that action at this time.
0 commit comments