Create ZK ancestors optimistically #52195
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Documentation entry for user-facing changes
When creating ZK ancestors, instead of going from root to last node, attempt to do it backwards as create leaves first.
For example, when creating ancestors for
/clickhouse/zero_copy/zero_copy_s3/c5b2eca0-b037-49a3-89b9-3ecad815f413/all_64146_64153_1/
the old behaviour would be:The new behaviour is optimistic and tries the last node first and only in case of failure it navigates the tree.
The worst case is much worse (2x requests), but the best case is much better (1 vs 5 requests). The thing is that the best case happens way more often than the worst (which never happens in fact as some parent nodes are always created earlier in the process).
This should help reducing the load in ZK caused by merges with zero copy replication, which requires an exclusive lock via ZK (tryCreateZeroCopyExclusiveLock):