Repository navigation
Fix flaky test_insert_into_distributed::test_reconnect - #117133
Merged
Merged
Conversation
The test broke the connection between a `Distributed` table and its remote shard, healed it, and then waited a fixed 5 seconds for the background sender to deliver the two pending inserts. That wait races the sender's retry interval: every failed attempt doubles it, starting at `background_insert_sleep_time_ms` (100 ms) and growing up to `background_insert_max_sleep_time_ms`, which defaults to 30 seconds. A newly inserted file does not shorten an interval the sender is already waiting out, because `addFileAndSchedule` calls `scheduleAfter` with `overwrite = false`, which is a no-op for an already delayed task. So the test could see only the first row and fail with `assert '1' == '3'`. Measured with two local servers, stopping and restarting the shard in place of the network partition: after a 60 second outage the sender's `error_count` reaches 9, which saturates the interval at the 30 second cap, and all rows arrive 20.2 seconds after the shard comes back - four times the 5 seconds the test allowed. With `background_insert_max_sleep_time_ms = 1000` the same scenario delivers everything in 1.5 seconds. The test now caps that setting on its table and waits for the observable state instead of sleeping: for the rows to appear on the shard, and - in place of the sleep that was there to let the send fail while the connection was down - for `error_count` in `system.distribution_queue` to grow. The latter also states the intent explicitly, that healing the partition has to exercise a reconnection. The test has never failed on `master`; in the last 90 days it failed four times, all of them on pull requests and all in instrumented builds (two under `amd_llvm_coverage`, two under `amd_msan`), which is what a slow machine accumulating more failed attempts inside the same partition window looks like. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114747&sha=ad14224d5f960e11c6fddf144128ac30beed5cc8&name_0=PR&name_1=Integration%20tests%20%28amd_llvm_coverage%2C%206%2F8%29 Related: #114747 Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
|
Workflow [PR], commit [91963a6] Summary: ✅ AI ReviewSummaryThis PR makes Final VerdictStatus: ✅ Approve |
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.
test_insert_into_distributed::test_reconnectbreaks the connection between aDistributedtable and its remote shard, heals it, and then waits a fixed 5 seconds for the background sender to deliver the two pending inserts. That wait races the sender's retry interval: every failed attempt doubles it, starting atbackground_insert_sleep_time_ms(100 ms) and growing up tobackground_insert_max_sleep_time_ms, which defaults to 30 seconds. A newly inserted file does not shorten an interval the sender is already waiting out, becauseaddFileAndSchedulecallsscheduleAfterwithoverwrite = false, which is a no-op for an already delayed task. When the interval outgrows the 5 seconds, the test sees only the first row and fails withassert '1' == '3'.Measured with two local servers, stopping and restarting the shard in place of the network partition: after a 60 second outage the sender's
error_countreaches 9, which saturates the interval at the 30 second cap, and all rows arrive 20.2 seconds after the shard comes back — four times the 5 seconds the test allowed. Withbackground_insert_max_sleep_time_ms = 1000the same scenario delivers everything in 1.5 seconds.The test now caps that setting on its table and waits for the observable state instead of sleeping: for the rows to appear on the shard, and — in place of the sleep that was there to let the send fail while the connection was down — for
error_countinsystem.distribution_queueto grow. The latter also states the intent explicitly, that healing the partition has to exercise a reconnection. The setting is scoped to this test:instance_test_reconnect, itsdistributedtable andlocal1are used by no other test in the file.The test has never failed on
master. In the last 90 days it failed four times, all of them on pull requests and all in instrumented builds (two underamd_llvm_coverage, two underamd_msan) — which is what a slow machine accumulating more failed attempts inside the same partition window looks like. There is no tracking issue for it.CI report of the failure this came from: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114747&sha=ad14224d5f960e11c6fddf144128ac30beed5cc8&name_0=PR&name_1=Integration%20tests%20%28amd_llvm_coverage%2C%206%2F8%29
Related: #114747
Changelog category (leave one):
Workflow [PR]
Sync PR [sync-upstream/pr/117133]
Version info
26.9.1.397(included in26.9and later)