Add support for preprocessing ZooKeeper operations in clickhouse-keeper#37036
Merged
Add support for preprocessing ZooKeeper operations in clickhouse-keeper#37036
clickhouse-keeper#37036Conversation
a0b63b6 to
a988cfa
Compare
antonio2368
commented
May 11, 2022
alesapin
reviewed
May 16, 2022
antonio2368
commented
May 17, 2022
antonio2368
commented
May 17, 2022
Co-authored-by: Antonio Andelic <[email protected]>
Co-authored-by: Antonio Andelic <[email protected]>
Member
|
Failures unrelated, but let's check one more time. |
Member
|
@Mergifyio update |
Contributor
✅ Branch has been successfully updated |
Member
|
|
Member
|
Failures are unrelated. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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):
Currently, Keeper applies the operation only after the commit.
To support real-time digest check of operation results, we need to preprocess the operation at least on the Leader node so each Raft log can be replicated with it afterwards.
This is only the first step for adding support for digests.
Multiple operations can be batched for replication so we cannot calculate the digest by analysing possible changes a single operation will make, we need to process those operations in some way without committing them.
Additionally, the goal was to minimise load on the leader, a possible solution would be to process the requests twice on the leader, first time applying it to some in-memory store, and second time to the real storage but that would require some complex interaction with NuRaft because KeeperStorage would need to be aware of the current role of the node it's running on.
Because of the reasons above, I implemented preprocessing for all the operation in a such way that they minimise the commit itself.
In short, preprocessing transforms the ZooKeeper request in set of deltas.
Those deltas have 2 roles:
Deltas are kept entirely in-memory, so applying them should be fast enough, while the data copying is minimal.
Those deltas also play nicely with the NuRaft interface (precommit -> transform into deltas, rollback -> simply delete deltas). If some node becomes a leader, it already has everything preprocessed and it can instantly continue processing the requests without any buildup beforehand.
Things left to do:
SessionTracker) - should be okay because fetching the SessionID is a blocking operation, i.e. nothing else can be done until the new session is committed