Repository navigation
[MOD-17410] Introduce QueryRequest base state for aggregate and hybrid requests - #10877
Conversation
d470efd to
c906490
Compare
a873e0b to
a5a323c
Compare
93d3700 to
e46eedb
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c30134daaf
ℹ️ 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".
| QueryError_ClearError(&request->reply.err); | ||
| ChunkReplyState_Init(&request->reply); |
There was a problem hiding this comment.
Destroy reply contents before resetting state
When a blocked FAIL/RETURN_STRICT timeout wins after the worker stores rows but before the reply callback consumes them, BlockedRequestCtx_EndCycle calls this function to clean the unconsumed reply. Clearing only the error and then zeroing the structure makes reply.results and its SearchResult objects unreachable without invoking ChunkReplyState_Destroy; QueryRequest_Destroy also omits that former safety net. Repeated timed-out large queries can therefore cause sustained module-memory growth, so destroy the chunk state before reinitializing it.
AGENTS.md reference: AGENTS.md:L133-L133
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in local commit 363b68c62. QueryRequest_ResetReply() now calls ChunkReplyState_Destroy() before reinitializing the state, and QueryRequest_Destroy() uses the same reset path as an idempotent safety net. This preserves the existing cursor-cleanup ordering in QueryRequest_EndCycle() while releasing any unconsumed stored results and errors. Verified with the build plus 7 focused coordinator/standalone timeout and cursor-lifecycle tests.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #10877 +/- ##
==========================================
- Coverage 83.00% 82.22% -0.79%
==========================================
Files 607 632 +25
Lines 80798 82115 +1317
Branches 35690 37363 +1673
==========================================
+ Hits 67068 67520 +452
- Misses 13391 14248 +857
- Partials 339 347 +8
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:
|
| if (!request) { | ||
| return; | ||
| } | ||
| int previous = atomic_fetch_sub_explicit(&request->refcount, 1, memory_order_acq_rel); |
There was a problem hiding this comment.
Why not memory_order_release?
There was a problem hiding this comment.
Another thread may write request state before releasing its reference. If the refcount is what transfers ownership of that state to the final thread, the final decrement needs acquire semantics before destruction.
There was a problem hiding this comment.
ok. This is transitional anyway, right?
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 95767f3ed9
ℹ️ 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".
| int coord_aggregate_query_reply_empty(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, QueryErrorCode errCode) { | ||
|
|
||
| AREQ *req = AREQ_New(); | ||
| AREQ *req = AREQ_New(argv, argc); |
There was a problem hiding this comment.
Release retained arguments on profile parse failure
When a coordinator using ON_OOM RETURN handles a malformed FT.PROFILE ... AGGREGATE request without QUERY, AREQ_New(argv, argc) retains every command argument, but the following parseProfileArgs(...) == -1 branch returns without decrementing the request reference. Repeated requests containing large arguments therefore permanently retain those strings; release the request and clear its error state before returning.
AGENTS.md reference: AGENTS.md:L134-L134
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in bc60b180c. The profile parse-error path now decrements the request, releasing its retained arguments, and replies through QueryError_ReplyAndClear(). The module build passes.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bc60b180cf
ℹ️ 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".
| } | ||
|
|
||
| AREQ_Debug *debug_req = rm_realloc(AREQ_New(), sizeof(*debug_req)); | ||
| AREQ_Debug *debug_req = rm_realloc(AREQ_New(argv, argc), sizeof(*debug_req)); |
There was a problem hiding this comment.
Initialize request state after resizing the debug object
AREQ_New initializes the mutexes and condition variable embedded in QueryRequestAsyncState before this rm_realloc enlarges the containing allocation. If realloc moves it, the initialized pthread objects are copied to new addresses, which is undefined behavior; a debug aggregate/coordinator request using RETURN_STRICT can consequently hang or crash during timeout synchronization or destruction. Allocate the final AREQ_Debug object before initializing its QueryRequest state.
AGENTS.md reference: AGENTS.md:L284-L287
Useful? React with 👍 / 👎.
|
Resolves the conflict in src/coord/dist_aggregate.c and ports this branch onto the QueryRequest base-state refactor from #10877: - DistCursorReadTimeoutReturnStrictCallback: keep this branch's corrected comment (the pre-pipeline bail is reachable now that coordinator cursors carry a real spec ref) over master's stale "currently unreachable" wording, and take master's field rename, req->brc->reply.err -> req->base.reply.err. - Cursor::is_coord no longer exists; coordinator-ness is derived from the cursor id via CURSOR_IS_COORD. Ported the two uses this branch added: the counter selection in Cursor_FreeInternal and the RSCursorProfileCommand assert. Cursors_Reserve still selects on CursorList::is_coord, which master kept. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>



Describe the changes in the pull request
QueryRequestbase for AREQ and HybridRequest, and passively mirror the relevant legacy state into typed cursor, reply, registry, timeout, and async substructures.BlockedRequestCtxwithout changing current consumers or synchronization behavior in this PR.The mirrored legacy assignments are intentionally retained and marked with searchable
TODO($$$)comments. The temporary async state is expected to be consolidated after MOD-17486.Which additional issues this PR fixes
Main objects this PR modified
QueryRequest,QueryRequestTimeout, andQueryRequestAsyncStateAREQandHybridRequestMark if applicable
Release Notes
Internal refactoring only; existing request state remains authoritative and consumed by current code paths.
Validation
git diff --check