Repository navigation
Prepare the introduction of more keeper faults - #56917
Conversation
|
This is an automated comment for commit 6cf8c9b with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page Successful checks
|
|
It seems I will need to bring more commits from #56389. As the tests run in parallel, the moment you enable more faults (some ops had some disabled, and the refactor got rid of that) they all clash with each other more frequently so you see the lack of proper recovery more often, e.g. the |
|
|
Errors:
|
|
Failures:
|
| { | ||
| my_storage.enqueuePartForCheck(part_name, MAX_AGE_OF_LOCAL_PART_THAT_WASNT_ADDED_TO_ZOOKEEPER); | ||
| }); | ||
| LOG_TRACE( |
There was a problem hiding this comment.
@tavplubix Do you mind having a look at this changes, specially checking that rename_part_to_temporary(); in the case where the data wasn't written to keeper (to retry) is safe? Thanks!
There was a problem hiding this comment.
It seems it's not safe due to zero copy locks and the bug is also present when the block_id was created by a different replica concurrently
| if (my_is_internal) | ||
| { | ||
| String alive_node_path = my_zookeeper_path + "/stage/alive|" + my_current_host; | ||
| zk->deleteEphemeralNodeIfContentMatches(alive_node_path, ""); |
There was a problem hiding this comment.
It is worth a good comment. And probably it would be more convenient to hide deleteEphemeralNodeIfContentMatches() inside create() with zkutil::CreateMode::Ephemeral
There was a problem hiding this comment.
I would rather not hide it for now. In some places the ephemeral node is created as part of a transaction and in other places we might not want to automatically recreate the ephemeral node. It also introduces extra round trips that are not necessary if you are not recovering from an error (one to check, one to remove or waiting for a long time for it to be removed).
I'll refactor it a bit
|
Working on rebasing the PR after the fix for zero-copy locks |
This reverts commit e4becc0.
|
Reimplemented ZK retries to |
If there are no tables left merge() will keep throwing errors constantly
|
Everything green except Marking it as ready again after the last changes. cc @devcrafter in case you want to review the latest changes before merging |
|
Need to rebase on top of 57764 which fixes some of the same problems found and fixed in this PR Done |
Even if it's not related, let's not ignore it. We can start with using CI DB to find when it started to fail. And it helps to find the reason quite easily: #57568 (comment) |
|
The new failures appeared with the merge with master and they look related. Need to investigate more, but I took master's way of improving ZK retries on backup coordination instead of the one in this PR so most likely the problem is there. |
|
Failures:
I would love to not have to rebase this again 😉 |
It'd be nice to understand what has changed from latest review |
The last 2 rebases:
|
|
|
||
| system disable failpoint replicated_commit_zk_fail_after_op; | ||
| system disable failpoint replicated_merge_tree_commit_zk_fail_when_recovering_from_hw_fault; | ||
|
|
There was a problem hiding this comment.
Optional, but we could check that after disabling failpoints, we can insert
| { | ||
| if (!isEmpty()) | ||
| { | ||
| WriteBufferFromOwnString buf; |
There was a problem hiding this comment.
Shouldn't we create just a method which will do this logging? (it's copy/pasted code)
There was a problem hiding this comment.
I recovered the code by reverting partially the commit that removed it and kept it as-is for simplicity, but it could be improved / iterated in the future.
| }); | ||
|
|
||
| /// Independently of how many retries we had left we want to do at least one check of this inner retry | ||
| /// at least once so a) we try to verify at least once if metadata was written and b) we set the proper |
There was a problem hiding this comment.
It's too many "at least once"
| @@ -1019,22 +1038,6 @@ std::pair<std::vector<String>, bool> ReplicatedMergeTreeSinkImpl<async_insert>:: | |||
| { | |||
| zookeeper->setKeeper(storage.getZooKeeper()); | |||
There was a problem hiding this comment.
I'm not sure about moving this block to lock and commit stage. Probably, you could explain
There was a problem hiding this comment.
I moved it because the table being in read only only matters when we are going to add a new part/commit to ZK. If we only have checks left (for example in resolve_duplicate_stage) it doesn't make sense to not continue verifying because the table is stopped, as we can still return a proper response to the client.
A similar thing will happen for quorum for example (but it's not in this PR to keep in more concise). It's ok to check for quorum if the write succeeded but the table was set in read only after that.
devcrafter
left a comment
There was a problem hiding this comment.
@Algunenano My comments are mostly minor, except probably #56917 (comment). But if you think it's fine, please feel free to fix comments in follow-up PR
|
Failures:
|
…ncelled while the Keeper commit status is unknown When the Keeper multi request committing an INSERT ends with a hardware error (e.g. connection loss), the request may or may not have been applied, so `ReplicatedMergeTreeSinkImpl::commitPart` verifies the status with an `exists` check under `ZooKeeperRetriesControl`. The preservation logic previously lived in the `actionAfterLastFailedRetry` callback, which only runs when the retries are exhausted by Keeper errors: a `max_execution_time` timeout, `KILL QUERY` or any non-retryable exception thrown during the recovery bypassed it, the exception left `commitPart` and `MergeTreeData::Transaction` rolled back the local part. Keeper, however, could already contain the part metadata, the replication log entry and the deduplication block id, so the part became lost forever (replaced by an empty part by the part check), and retrying the same INSERT was silently deduplicated - permanent data loss. The regression exists since 23.12: the verify-first recovery introduced by ClickHouse#56917 interacts with the time limit checks between retries introduced by Now the recovery result is explicit: unless the recovery loop completes the Keeper checks and produces a result, the commit status is treated as unknown on any exit path, and the local part is preserved - committed locally and enqueued for a part check, which keeps it if it is present in Keeper or drops it otherwise. `actionAfterLastFailedRetry` is deliberately not used: its contract does not cover cancellation or non-retryable failures. On these paths the INSERT now fails with `UNKNOWN_STATUS_OF_INSERT` instead of `TIMEOUT_EXCEEDED` / `QUERY_WAS_CANCELLED`, consistently with the exhausted-retries path, so that clients do not interpret the failure as "the data was not inserted". Co-Authored-By: Claude Fable 5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Longer details:
Refactors ZooKeeperWithFaultInjection to prepare to introduce it in more places:
It reworks how part_committed_locally_but_zookeeper (old) / resolve_uncertain_commit_stage (less old) worked so that we can keep retrying in case the ZK session failed when committing. Before the uncertain stage could only be resolved if ZK failed after write (and in that case everything was good) but it wouldn't recover it data wasn't written to keeper. Now it recovers both cases.
Fixes an issue found related with ephemeral nodes cleaning up in backups fault and changes the name (
handleEphemeralNodeExistence->deleteEphemeralNodeIfContentMatches) to avoid further confusions. I included in this PR since changing the name and introducing faults is what leads to noticing the problem and enables fixing them only once (and not twice, one in a different PR and another time in the refactor)AFAICS. Closes #50465 as it removed the special handling of tryMulti() responses
cc @devcrafter