RFC: Eliminate race window between selecting parts to merge and merge entry creation#34013
RFC: Eliminate race window between selecting parts to merge and merge entry creation#34013azat wants to merge 2 commits intoClickHouse:masterfrom
Conversation
Signed-off-by: Azat Khuzhin <[email protected]>
…y creation
CI founds [1] intersecting parts while running 01459_manual_write_to_replicas test:
<details>
2022.01.15 23:07:24.387149 [ 750 ] {} <Debug> test_98ynp9.r4 (MergerMutator): Selected 9 parts from all_1_15_1 to all_31_31_0
2022.01.15 23:07:24.541640 [ 763 ] {} <Test> test_98ynp9.r4 (ReplicatedMergeTreeQueue): Insert entry queue-0000000020 to queue with type MERGE_PARTS with virtual parts [all_1_28_2]
2022.01.15 23:07:25.327639 [ 750 ] {} <Trace> test_98ynp9.r4: Created log entry /clickhouse/tables/01459_manual_write_to_replicas_test_98ynp9/r/log/log-0000000021 for merge all_1_31_2
# What goes after, not that important, just to show the error and the flow
...
2022.01.15 23:08:02.078376 [ 790 ] {} <Warning> test_98ynp9.r4 (ReplicatedMergeTreeRestartingThread): ZooKeeper session has expired. Switching to a new session.
...
2022.01.15 23:08:04.792227 [ 790 ] {} <Trace> test_98ynp9.r4 (ReplicatedMergeTreeQueue): Initializing parts in queue
...
2022.01.15 23:08:04.868563 [ 790 ] {} <Debug> test_98ynp9.r4 (ReplicatedMergeTreeQueue): Loading queue from /clickhouse/tables/01459_manual_write_to_replicas_test_98ynp9/r/replicas/r4/queue
2022.01.15 23:08:04.949219 [ 790 ] {} <Debug> test_98ynp9.r4 (ReplicatedMergeTreeQueue): Having 0 queue entries to load, 1 entries already loaded.
2022.01.15 23:08:05.398827 [ 790 ] {} <Debug> test_98ynp9.r4 (ReplicatedMergeTreeQueue): Pulling 1 entries to queue: log-0000000021 - log-0000000021
2022.01.15 23:08:05.417492 [ 790 ] {} <Test> test_98ynp9.r4 (ReplicatedMergeTreeQueue): Insert entry queue-0000000021 to queue with type MERGE_PARTS with virtual parts [all_1_31_2]
2022.01.15 23:08:05.424624 [ 790 ] {} <Fatal> : Logical error: 'Part all_1_31_2 intersects previous part all_1_28_2. It is a bug or a result of manual intervention in the ZooKeeper data.'.
</details>
[1]: https://s3.amazonaws.com/clickhouse-test-reports/33665/16adcc166608b922f7351a8eedcfb483d63d7513/stress_test__debug__actions_.html
The reason AFAICS that there is a race window between selecting parts to
merge and merge entry in zookeeper had been created, that you can see in
first 3 lines of the log.
Signed-off-by: Azat Khuzhin <[email protected]>
| if (queue.isVirtualPart(merged_info, merged_name)) | ||
| { | ||
| throw Exception(ErrorCodes::DUPLICATE_DATA_PART, | ||
| "There is already queue entry that intersects {} part", merged_name); | ||
| } | ||
|
|
There was a problem hiding this comment.
AFAIK if there is a covering part in the queue, then either ReplicatedMergeTreeMergePredicate::canMergeTwoParts returned false or zookeeper request will fail due to log version mismatch, so this change looks redundant. Could you please explain in more details where is the race condition and why this check is supposed to fix it?
There was a problem hiding this comment.
Yep, seems you are right, and this change is redundant.
|
There's nothing suspicious in logs (https://gist.github.com/tavplubix/29a621d09264dd9f142d862ac34762b6), seems like log version check did not work for some reason. Will try to check zookeeper_log. |
|
But there's no zookeeper_log_dump in stress tests... |
|
I've extracted some logs from Seems like when So probably we should look for a bug in |
I thought about some issues with replicas, but there is only one keeper instance, so this should not be a problem (in this case it will be interesting to see at zookeeper_log and host_address at which it was connected)
Indeed, It should got merges_version=3, but it seems that it did not load all_1_28_2 into the queue in-memory. Here are some my observations: |
|
Closed in favor of #34096 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Eliminate race window between selecting parts to merge and merge entry creation (fix one more case of
Logical error: 'Part X intersects previous part Y. It is a bug or a result of manual intervention in the ZooKeeper data.'.error)CI founds 1 intersecting parts while running 01459_manual_write_to_replicas test:
Details
The reason AFAICS that there is a race window between selecting parts to
merge and merge entry in zookeeper had been created, that you can see in
first 3 lines of the log.
Refs: #26876
Cc: @tavplubix
Cc: @alesapin