Repository navigation
Fix flaky test_keeper_4lw_reconfiguration by not zeroing a possible leader's priority - #113988
PedroTadim merged 4 commits into
Conversation
…eader's priority test_reconfig_option2 failed in Integration tests (amd_tsan, 6/6) with assert 'error' == 'ok' inside three_to_five_reconfig, after rcfg returned error with Code: 159 TIMEOUT_EXCEEDED 126 seconds in. Four more hits over 60 days of CIDB, two of them on master. The command plan was only valid if no election happened while it ran. It issued transfer_leadership to the joining servers 6 and 7 while servers 4 and 5 were still at priority 100, equal to 6 and 7, and zeroed 4 and 5 only in the last action. checkReconfigCommandActions validates set_priority ... priority == 0 against a static state model in which the transfer has already made 6 and 7 the only possible leaders, so the plan passed the pre-check. In the failing run two elections landed inside that window (term 5 to server 4, term 6 back to server 5), so the last action asked server 5 to zero its own priority while it was leader. NuRaft refuses that by design and tells you to step down first, and Keeper's own pre-check rule says the same, so the server behaved correctly. The plan was invalid at the moment it executed, not merely unlucky. Lower servers 4 and 5 to priority 1 in the first action instead of leaving them at 100. A node whose priority is below target_priority_ declines to initiate a pre-vote, and target_priority_ is 100 once 6 and 7 join, so 4 and 5 cannot win an election inside the window; meanwhile yield_leadership still nominates the highest-priority responsive peer, 6 or 7, and sends it a dummy append-entries to trigger its election at once. Priority 1 rather than 0 is deliberate: 0 would be self-refused by the same NuRaft rule and would make a leader resign shortly after winning. Every assertion is unchanged, including the final priorities, and all four action types are still exercised. Measured over three module runs each way: with the change, servers 4 and 5 are never eligible to initiate an election inside the window (2 observations, both gated at target 80 mine 1); without it they are (1 observation, eligible at target 80 mine 100). The pass/fail arms agree, which is expected at this failure rate and is not offered as evidence. This narrows the window rather than closing it absolutely, since target_priority_ decays 100, 80, 64, 52, 42, 32, 22, 12, 2, 1 over nine election timeouts, so a priority-1 node becomes eligible again after roughly 9 to 18 seconds of both 6 and 7 being unresponsive. Also swap two format arguments in the TIMEOUT_EXCEEDED message, which printed the action where the retry count belongs and the count where the action belongs, making an already confusing failure unreadable. Not fixed here, deliberately: applyConfigUpdate discards set_priority_v2's return value, so a refused priority change is logged as accepted and surfaces as this timeout instead of the real reason. Reading that bool is unsound because Keeper sets return_method_ to async_handler, so false also means forwarded and still in flight, and a config-observing check cannot see an accepted-but-uncommitted change. applyConfigUpdateWithReconfigDisabled drops the same value on the legacy path for the same reason. The retry field is still capped to 1 by a std::min where std::max was meant; that is not part of this failure and cannot be lifted without also bounding the total wait.
Internal second-model review (click to expand)Reviewed cold against the code on disk before reading the author's evidence, then a
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20260808-192800 |
|
cc @Michicosun @alesapin, could you review this? The |
|
Workflow [PR], commit [bf81745] Summary: ✅
AI ReviewSummaryThis PR changes the Findings❌ Blockers
Final VerdictChanges requested. The retry-count diagnostic hunk is not correct until the LLVM Coverage ReportMeasured on commit bf81745.
Changed lines: Changed C/C++ lines covered: 0/2 (0.00%) · Uncovered code |
CI finish ledger - 4930a2cEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Neither red is PR-caused: this PR touches Session id: cron:our-pr-ci-monitor:20260809-033000 |
|
@groeneai is this fix still needed? |
|
Yes, still needed as far as I can measure. Still firing: the exact assertion this PR targets ( Still applicable: neither hunk is superseded. Two limits, both stated in the description: it narrows the window rather than closing it, since |
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
|
CI finish ledger - ad1ce99Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
172 of 177 checks are green here, including Session id: cron:our-pr-ci-monitor:20260918-130143 |
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| LOG_INFO(log, "Timeout exceeded waiting for configuration update {} to be applied, attempt {}/{}", action, attempt + 1, retry_count + 1); | ||
| } | ||
| throw Exception(ErrorCodes::TIMEOUT_EXCEEDED, "Timeout exceeded (with retries count {}) waiting for configuration update {} to happen", action, retry_count); | ||
| throw Exception(ErrorCodes::TIMEOUT_EXCEEDED, "Timeout exceeded (with retries count {}) waiting for configuration update {} to happen", retry_count, action); |
There was a problem hiding this comment.
retry is still silently capped at 1 before we get here: reconfigureClusterFromReconfigureCommand initializes retry_count to 1 and then does std::min(retry_count, action_obj->getValue<int64_t>("retry")) at src/Coordination/KeeperDispatcher.cpp:1105-1107. A request like the PR's own {"retry": 3} therefore still gets at most two attempts, and this timeout now reports 1 instead of the requested retry budget.
Since this hunk is specifically fixing the TIMEOUT_EXCEEDED diagnostic, I think we need to fix the parser side as well (assign/validate the requested count instead of clamping it down to 1), otherwise the command contract and the message still disagree.
There was a problem hiding this comment.
Confirmed at head bf81745: the clamp is real and the line numbers are right.
:1105 int64_t retry_count = 1;
:1107 retry_count = std::min(retry_count, action_obj->getValue<int64_t>("retry"));
:876 for (int64_t attempt = 0; attempt <= retry_count; ++attempt)
{"retry": 3} therefore yields 1, so two attempts, and checkReconfigCommandActions (:955) never validates the field either, so a negative value also reaches the loop, skips it entirely and reports retries count -1 for an action that was never pushed.
One correction to the framing: after this hunk the message and the code agree. retry_count is the budget the run actually used, and the catch-all at :1251 hands that same string back as the rcfg payload, which is what assert result["status"] == "ok" reads in the flaky run. What contradicts the request is the parse, not the diagnostic.
I would rather not change the parse in this PR, because honoring the budget changes the wait contract of the test this PR is stabilizing:
three_to_five_reconfigsetsmax_action_wait_time_msto 30000 and callsrcfgwith a 180 s client timeout.add_membersis bounded by 2 x 30 s today and by 4 x 30 s onceretry: 3is honored, taking the worst case for the whole command from 240 s to 300 s against that 180 s budget.- The extra attempts only start after one has already timed out, so they cannot rescue a healthy run. They can only replace the structured error this test asserts on with no answer at all, which is the
test_reconfig_option1failure shape on the same file. time_left_totalis recomputed per action (:1100), never between attempts, somax_total_wait_time_msdoes not bound it either.
So the parse fix wants validation plus a per-action budget that the client timeout can actually bound, reviewed together rather than folded into a two line diagnostic and test fix. If it should go in here anyway, say so and I will add it with those budgets in the same push.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 13 s compile time in total, 7 of them have a recent master baseline. |
Related: #113595 (comment)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
test_reconfig_option2failed inIntegration tests (amd_tsan, 6/6)withassert 'error' == 'ok'insidethree_to_five_reconfig(report).
It fired on four other days in the previous 60 of CIDB, twice on master.
The command plan was only valid if no election happened while it ran: it transferred leadership
to the joining servers 6 and 7 while 4 and 5 were still at priority 100, and zeroed 4 and 5 only
in the last action.
checkReconfigCommandActionsvalidated it against a static model in whichthe transfer had already made 6 and 7 the only leaders, so it passed the pre-check. Two elections
then landed in that window, so the last action asked server 5 to zero its own priority while
leader. NuRaft refuses that by design: the server was right, the plan was not.
I lower 4 and 5 to priority 1 in the first action. A priority-1 node will not initiate a pre-vote
against a target priority of 100, while
yield_leadershipstill nominates 6 or 7 and triggerstheir election at once. Priority 1 rather than 0 is deliberate: 0 is self-refused by the same
rule, and makes a leader resign shortly after winning. All assertions and action types are
unchanged. Over three runs each way, 4 and 5 are eligible to start an election in that window
without the change and never with it. This narrows the window rather than closing it, since
target_priority_decays to 1 after nine election timeouts.I also swap two format arguments in the
TIMEOUT_EXCEEDEDmessage, which printed the action andthe retry count in each other's slot.
Not fixed here:
applyConfigUpdatediscardsset_priority_v2's return value, so a refusalsurfaces as this timeout rather than its real reason. Reading that bool is unsound, since
falsealso means "forwarded, still pending".Workflow [PR]
Sync PR [sync-upstream/pr/113988]