Repository navigation
[MOD-16989] Split RequestSyncCtx into embedded RequestSyncState and heap BlockedRequestCtx wrapper (step 0) - #10336
Conversation
- Rename embedded sync state from RequestSyncCtx to RequestSyncState (fields: timedOut, abortWakeChannel, abortWakeLock) - Add heap-allocated RequestSyncCtx wrapper owning the top-level query (kind + AREQ/HybridRequest union, aggregate-results coordination fields, refcount) - Add back-pointer rsc (non-owning) on AREQ and HybridRequest - Implement RequestSyncCtx_NewAREQ / RequestSyncCtx_NewHybrid / RequestSyncCtx_Free constructors/destructor - Add RequestSyncCtx_IncrRef / RequestSyncCtx_DecrRef refcount helpers - Rewrite AREQ_IncrRef / AREQ_DecrRef / HybridRequest_IncrRef / HybridRequest_DecrRef to delegate to the wrapper - Make AREQ_Free public (called by DecrRef on last drop) - Migrate aggregate-coordination field accesses to req->rsc->... - Insert RequestSyncCtx_New* calls at all top-level query creation sites (aggregate_exec, reply_empty, aggregate_debug, dist_aggregate, hybrid_request) - Fix stale RequestSyncCtx_* call names -> RequestSyncState_* in dist_aggregate.c, rpnet.c, dist_hybrid.c - Add #include hybrid/hybrid_request.h to aggregate_request.c - Fix __atomic_* int* cast for _Atomic(int) refcount field
After the split, the heap wrapper's job is ownership plus the blocked-client cycle handle — not synchronization — so the sync name stays with the embedded slice (RequestSyncState) and the wrapper takes a name matching the Blocked* / *Ctx conventions. Back-pointer field renamed rsc -> brc. Pure mechanical rename; Rust doc comments that referenced the timedOut flag now point at RequestSyncState. Co-Authored-By: Claude Fable 5 <[email protected]>
A shard _FT.HYBRID ... WITHCURSOR creates one cursor per subquery with cursor->execState pointing at the sub-AREQ. A RETURN_STRICT FT.CURSOR READ on such a cursor runs the claim/done-latch handshake against the read AREQ's wrapper (req->brc->requiresAggregateResultsSync, AREQ_TryClaimAggregateResults, AREQ_ResetForCursorReadReturnStrict) — which was NULL for sub-AREQs, a guaranteed crash on the strict hybrid sub-cursor read path. Wrap each cursor-backing sub-AREQ at HybridRequest_StartCursors time, preserving today's per-sub-AREQ handshake granularity. Ownership is unchanged: the hybrid request still owns the sub-AREQ, and the wrapper is freed with it (HybridRequest_Free -> AREQ_DecrRef -> BlockedRequestCtx_Free). Non-cursor sub-AREQs stay unwrapped. Co-Authored-By: Claude Fable 5 <[email protected]>
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #10336 +/- ##
==========================================
+ Coverage 82.32% 82.34% +0.01%
==========================================
Files 570 570
Lines 76921 76962 +41
Branches 31836 31836
==========================================
+ Hits 63328 63371 +43
+ Misses 13297 13295 -2
Partials 296 296
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…1 atomics - AREQ_RequiresThreadsSyncResults asserts req->brc != NULL (debug-only) instead of silently dereferencing: every request reaching the strict-sync protocol is wrapped by construction, and that stays true at the refactor's end state, so an unwrapped caller is a bug we want to catch loudly. - BlockedRequestCtx_NewAREQ/NewHybrid assert the request is not already wrapped (double-wrap would silently leak the first wrapper); drop the now-redundant call-site assert in HybridRequest_StartCursors. - Drop the BlockedRequestCtx wrappers in reply_empty.c: these transient AREQs only flow through the reply-only chunk sender and AREQ_DecrRef, which both handle unwrapped requests (as coord_aggregate_query_reply_empty already demonstrated). - Use C11 atomic_fetch_add/sub_explicit on the wrapper refcount instead of __atomic builtins through a qualifier-stripping cast, matching the file's existing atomics idiom. (Refcount is removed entirely in Step 2.) Co-Authored-By: Claude Fable 5 <[email protected]>
# Conflicts: # src/aggregate/aggregate_request.c # src/redisearch_rs/rqe_iterators/src/utils/timeout.rs
lerman25
left a comment
There was a problem hiding this comment.
Some inital comments.
Let's discuss this in-person
The type was renamed to RequestSyncState in this PR but the instances kept the old name. Also rename RPSafeLoader's BlockedRequestCtx pointer (formerly also named syncCtx) to brc, matching the AREQ back-pointer convention, since it is a wrapper pointer and not a RequestSyncState. Co-Authored-By: Claude Fable 5 <[email protected]>
# Conflicts: # src/aggregate/aggregate.h
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9b976f60f
ℹ️ 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".
Co-Authored-By: Claude Fable 5 <[email protected]>
|



Describe the changes in the pull request
Step 0 of the blocked-client / cross-thread ownership refactor designed in #9426 (refreshed there against post-RETURN_STRICT master).
RequestSyncCtxis embedded inside everyAREQ/HybridRequestand conflates three jobs: the request's lifetime refcount, the per-request timeout signal (timedOut + abort-wake channel), and the top-level RETURN_STRICT result-production coordination (claim CAS, claim-lost flag, done-latch, safe-loader-GIL handshake).RequestSyncStatestays embedded on every request (hybrid sub-AREQs included): onlytimedOut+ the abort-wake channel.BlockedRequestCtxis a new heap-allocated wrapper that owns the top-level AREQ/HybridRequest and hosts the RETURN_STRICT coordination block verbatim. Requests reach it via a non-owningreq->brcback-pointer, so all handshake call-sites keep their signatures.AREQ_IncrRef/AREQ_DecrRefdelegate throughreq->brc); it is removed in a later step when the wrapper becomes blocked-client privdata with single-owner transfer semantics.HybridRequest_StartCursorstime — a RETURN_STRICTFT.CURSOR READon a sub-cursor runs the claim handshake against the read AREQ's wrapper, which would otherwise be NULL.safeLoaderHoldingGILbecomes a counter on the wrapper: hybrid tail + subquery safe loaders now share one wrapper, and with a bool one loader's ExitGIL would erase another's "parked at the GIL gate" mark, letting the strict timeout callback deadlock in Wait.test_blocked_client_timeout.py(54/54),test_hybrid_timeout.py(30/30),test_cursors.py(28/28).Which additional issues this PR fixes
Main objects this PR modified
RequestSyncCtx→RequestSyncState(embedded) +BlockedRequestCtx(heap wrapper),src/aggregate/aggregate.h/aggregate_request.cAREQ/HybridRequest(syncCtxslimmed,brcback-pointer)aggregate_exec.c,hybrid_exec.c,dist_aggregate.c,dist_hybrid.c,coord_request_ctx.c,rpnet.c,result_processor.c)Mark if applicable
Release Notes
🤖 Generated with Claude Code