Repository navigation
[8.8] [MOD-18502] Move coordinator AGGREGATE FAIL reply serialization off the main thread - #11590
Conversation
…he main thread (#11552) * [MOD-18502] Move coordinator AGGREGATE FAIL reply serialization off the main thread * [MOD-18502] Avoid duplicate timeout accounting for discarded background replies * [MOD-18502] Discard early worker errors after timeout replies * test: tolerate background PROFILE timeout warning accounting * [MOD-18502] Stop collecting shard profiles after FAIL cancellation * [MOD-18502] Wake coordinator reply waits on FAIL timeout
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee42a4f1eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| static bool profileShouldStopCollectingReplies(AREQ *req) { | ||
| // A cancelled FAIL reply is discarded, so there is no need to collect more shard profiles. | ||
| return req->reqConfig.timeoutPolicy == TimeoutPolicy_Fail && AREQ_TimedOut(req); |
There was a problem hiding this comment.
Use the dispatch mode when stopping profile collection
If a coordinator PROFILE request is dispatched while ON_TIMEOUT is FAIL, queued, and the setting changes to RETURN before AREQ_New() runs, encodeReplyInBackground still selects the callback-free FAIL path while reqConfig.timeoutPolicy becomes RETURN. After the blocked-client deadline wakes a worker waiting for a shard profile, this predicate remains false, so printAggProfile() repeatedly calls getNextReply() even though the abort flag makes it return RS_RESULT_TIMEDOUT; that coordinator worker never completes. Test the dispatch snapshot (encodeReplyInBackground) rather than the later configuration snapshot.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 22cd906. The PROFILE stop predicate now uses encodeReplyInBackground, captured at dispatch, instead of the policy read later by AREQ_New. Added a regression that queues PROFILE under FAIL, changes CONFIG to RETURN, and cancels while a shard profile is missing. The previous binary failed to complete the worker; the fixed regression passes. Validation: assertion-enabled debug build, 978 C/C++ unit tests, and 45 clustered timeout test cases passed. This mismatch is specific to the 8.8 adaptation; the original merged implementation restores the captured policy through applyCoordReqConfigTimeoutPolicy.
| } | ||
| #endif | ||
| // The timeout callback already counted errors for discarded background replies. | ||
| const bool countError = !(req->encodeReplyInBackground && AREQ_TimedOut(req)); |
There was a problem hiding this comment.
Arbitrate timeout error accounting atomically
When a coordinator FAIL deadline races an expression or pipeline error, the worker can evaluate countError as true and then be descheduled while the timeout callback sets timedOut and increments the timeout metric; on resumption the worker increments an error metric for the same discarded reply. The analogous check in AREQ_ReplyOrStoreError() has the same check-then-act race. Use a shared atomic ownership/once flag for error accounting rather than sampling timedOut before updating the counters.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
We accept this limitation, as already agreed for the source PR #11552. Error accounting is best effort: a worker that passes the timeout-state check can still count an error for a subsequently discarded reply, including a second timeout count. We are okay with those metric increments and will not add atomic accounting ownership or additional synchronization in this PR. This is documented in the PR description.
| if (reqCtx->type == COMMAND_AGGREGATE && reqCtx->encodeReplyInBackground && | ||
| RedisModule_BlockedClientDisconnected(ctx)) { | ||
| // A discarded reply must not leave its pending cursor idle. | ||
| CoordRequestCtx_SetTimedOut(reqCtx); |
There was a problem hiding this comment.
Wake profile workers when blocked clients disconnect
For a coordinator FAIL FT.PROFILE request with TIMEOUT 0 (or a long deadline), a client can disconnect while printAggProfile() is waiting for a shard's final profile, leaving the worker blocked in getNextReply(). This free-data callback runs only after threadHandleCommand() returns and unblocks the client, so setting timedOut here is too late to wake that worker; an unresponsive shard plus disconnect can therefore consume a coordinator thread indefinitely, and repeated requests can exhaust the pool. Propagate disconnect cancellation while the handler is still running or avoid draining profiles after the blocked client is gone.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid concern; free-data cleanup cannot wake a worker that has not yet completed. We are keeping disconnect cancellation separate from this serialization backport. Existing tracking is MOD-18986 (https://redislabs.atlassian.net/browse/MOD-18986), under MOD-16298, which explicitly requires cancellation to wake blocked PROFILE reply waits and terminate collection. MOD-18916 (https://redislabs.atlassian.net/browse/MOD-18916) covers the broader disconnect-handling backport specifically for 8.10. Both are currently To Do. This limitation also applies to the original #11552 and is now documented in this PR description; no duplicate ticket was created.
|


Describe the changes in the pull request
Backport of #11552 (
58e0e440b59500a88aa207a3642f4afa3c8032cb) to8.8.Coordinator AGGREGATE with
ON_TIMEOUT FAILnow serializes replies on workers while retaining the blocked-client deadline through encoding. Preserve complete-chunk error semantics, finalize pending cursors during blocked-client cleanup, and wake cancelled PROFILE workers waiting for shard replies.Adaptations for 8.8
CoordRequestCtx; reuse this branch's existing FAIL timeout callbacks and cursor policy snapshot. Do not import the newer timeout-policy API or RETURN_STRICT cursor lifecycle.QEXEC_F_BUILDPIPELINE_NO_ROOTfor the existing coordinator predicate.Queued policy-change regression
PROFILE cancellation now checks the background-encoding mode captured at dispatch. A request dispatched under FAIL can otherwise read RETURN when the worker creates its AREQ, then spin after cancellation while waiting for shard profiles. The new regression queues PROFILE under FAIL, changes CONFIG to RETURN, and verifies cancellation releases the worker before the missing shard resumes. It reproduced the worker failing to finish on the previous binary and passes with this fix.
The follow-up debug build and all 978 C/C++ tests passed. The complete three-shard timeout file passed with 45 actual PASS entries and no failures (RLTest reports 58 including skips).
Validation
test_blocked_client_timeout: 36 standalone test cases passed; 44 three-shard cluster test cases passed. The initial clustered run passed 42 cases; the two parity tests were adapted for the release differences above and both passed on targeted rerun. Counts exclude displayed SKIP entries rather than relying on RLTest's headline totals, which include skips.Accepted limitations inherited from the source PR
Which additional issues this PR fixes
MOD-18502
Main objects this PR modified
test_blocked_client_timeout.py.Mark if applicable
Release Notes