Skip to content

[MOD-13617] [Agg] Coordinator handle return-strict - #9234

Merged
lerman25 merged 24 commits into
masterfrom
omerl-agg-coord-return-strict
Apr 29, 2026
Merged

lerman25 merged 24 commits into
masterfrom
omerl-agg-coord-return-strict

Conversation

@lerman25

@lerman25 lerman25 commented Apr 22, 2026 •

Copy link
Copy Markdown
Collaborator

Wires coordinator-level FT.AGGREGATE onto the ON_TIMEOUT RETURN_STRICT path: on a blocked-client timeout, the coordinator returns whatever shard results have already been admitted through a strictly-streaming pipeline, plus a timeout warning, instead of failing the query. Mirrors the FT.SEARCH counterpart shipped in MOD-13831 (#8236) and builds on the FT.AGGREGATE FAIL wiring from MOD-14086 (#8752).

Parent epic: MOD-8477 Revisit and improve the query engine timeout mechanism.

Why

RETURN_STRICT guarantees the user-requested timeout is honored end-to-end while still surfacing any partial results the pipeline has already accumulated, provided those partial results are valid answers to the query. Before this PR, coordinator FT.AGGREGATE only supported FAIL on the blocked-client path.

Design

Two concurrent actors, one reply, classified by pipeline shape:

  • Main thread — runs the blocked-client timeout_callback (DistAggregateTimeoutReturnStrictClient). Once entered, it owns the reply (per docs/redis-blocking-client-internals.md: after timeout_callback fires, bc->client is NULL, so reply_callback is skipped).
  • Background (BG) worker — runs the pipeline; on timeout it stops admitting more shard results, propagates RS_RESULT_TIMEDOUT upward, stores whatever the pipeline has produced so far, and signals the main thread.
Pipeline classification: yieldsPartialResults

The coordinator pipeline is classified as yielding partial results iff its shape is exactly RPNet → RPPager_Limiter → end — every admitted row is a final, unmodified shard row, so any prefix of the output is a valid (incomplete) answer. The classifier pipelineYieldsPartialResults(AREQ*) is called at the end of buildDistRPChain; the resulting flag lives on QueryProcessingCtx.yieldsPartialResults. Profile is excluded for now (RPProfile wraps every RP and isn't yet supported under the drain path).

Future operators that gain partial-correctness (e.g. an incremental sorter that emits ordered batches as input arrives) join this set without renaming — the field describes a semantic property, not a structural shape.

Two protocols, by class:
  • yieldsPartialResults == true → drain. After BG aborts and signals, the main thread enables RPNet.drainOnly = true and pulls remaining queued shard replies via endProc->Next directly. drainOnly mode pops non-blocking and maps timeouts to RS_RESULT_EOF. The pager's remaining and qctx->resultLimit honor the user's LIMIT naturally. Reply: partial rows + total_results + timeout warning.
  • yieldsPartialResults == false → discard. Buffering operators (RPSorter, RPGroup, RPDepleter) propagate RS_RESULT_TIMEDOUT in O(1) under RETURN_STRICT and drop any rows they had buffered — emitting a "sorted prefix" or partial group counts would be structurally incorrect, not just incomplete. The reply path zeroes qctx->totalResults to keep total_results consistent with results: [], then calls the standard AREQ_ReplyWithStoredResults. Reply: results: [] + total_results: 0 + timeout warning.
Three-region timeout model:

The CAS handshake (AREQ_TryClaimAggregateResults) splits BG execution into three regions, each handled differently when the timeout fires:

Region BG state Main-thread action Reply
Pre-claim BG hasn't entered the pipeline Main wins CAS → BG bails on post-claim TimedOut check coord_aggregate_query_reply_empty (empty + warning)
In-pipeline BG owns the claim, mid-execution WakeAbortChannel → BG returns TIMEDOUT from getNextReply, runs discard/store path, signals AREQ_ReplyWithStoredResults + (drain for yieldsPartialResults, zero-total_results for the discard class)
Post-store BG already stored, about to signal Main parks in WaitForAggregateResultsComplete; BG signal releases it AREQ_ReplyWithStoredResults (full or partial set)
Synchronization primitives (RequestSyncCtx on AREQ):
  • requiresAggregateResultsSync — gate (set when timeoutPolicy == RETURN_STRICT; temporary until shard-level lands).
  • aggregatingResults (atomic) — CAS claim flag. BG winner runs the pipeline and stores results; timeout-callback winner preempts BG and replies empty.
  • aggregateResultsDone + aggregateResultsLock + aggregateResultsCond — completion signal; the loser parks here until the winner finishes.
  • abortWakeChannel + abortWakeLock — single-slot registration so the main thread can wake BG out of a blocking MRChannel_Pop when a shard is unresponsive.

Implementation

1. Synchronization scaffolding (src/aggregate/aggregate.h, src/aggregate/aggregate_request.c, src/aggregate/aggregate_exec.c, src/coord/dist_aggregate.c, src/module.c)

  • New RequestSyncCtx fields and RequestSyncCtx_Init / _Destroy; destroy is wired into both AREQ_Free and HybridRequest_Free for reuse.
  • AREQ_TryClaimAggregateResults, AREQ_SignalAggregateResultsComplete, AREQ_WaitForAggregateResultsComplete, AREQ_ResetAggregateResultsClaim (the last one allows cursor chunks to re-enter the protocol).
  • startPipeline gate: if requiresAggregateResultsSync and CAS loses, BG exits early; otherwise BG runs startPipelineCommon and unconditionally signals on exit (even on error — the loser must never stick).
  • DistAggregateTimeoutReturnStrictClient: under CoordRequestCtx's setReqLock → SetTimedOut → fetch AREQ → wake the abort channel; if no request or CAS wins, reply empty with TIMED_OUT warning; otherwise wait for BG's signal, run drainPartialResultsAfterTimeout (no-op for non-yielding pipelines), then reply from storedReplyState via AREQ_ReplyWithStoredResults (zeroing totalResults first if the pipeline doesn't yield partial results and the buffer ended up empty).
  • DistAggregateCommandImp picks the timeout callback by policy (FAIL → existing DistAggregateTimeoutFailClient; RETURN_STRICT → new callback). The reply callback is shared — ChunkReplyState is policy-agnostic.

2. Pipeline classification + drain mode (src/coord/dist_aggregate.c, src/coord/rpnet.{h,c}, src/result_processor.h)

  • pipelineYieldsPartialResults(AREQ*) — structural classifier; called at the end of buildDistRPChain to set qctx->yieldsPartialResults.
  • RPNet.drainOnly — plain bool (set by main thread after BG has exited the pipeline; no concurrent reader). rpnetNext checks it on every entry: pop non-blocking, map any timeout signal to RS_RESULT_EOF.
  • drainPartialResultsAfterTimeout(AREQ*) — main-thread helper. Early-returns if yieldsPartialResults == false. Otherwise sets drainOnly, then loops endProc->Next until resultLimit is exhausted or Next stops returning OK, appending to storedReplyState.results.

3. Buffering-operator timeout discard (src/result_processor.c)

  • RPDepleter_Next_Accumulate: after RPDepleter_Deplete returns, if last_rc == RS_RESULT_TIMEDOUT && timeoutPolicy == TimeoutPolicy_ReturnStrict, return RS_RESULT_TIMEDOUT immediately instead of switching to yield mode and emitting buffered rows.
  • RPSorter and RPGroup propagate upstream RS_RESULT_TIMEDOUT without yielding their buffer (RPSorter via the existing RPSORT_DiscardOnTimeout policy; RPGroup via natural propagation).

4. Blocked-reader bailout via MR channel broadcast (src/coord/rmr/chan.{h,c}, src/coord/rmr/rmr.{h,c}, src/coord/rpnet.c, src/coord/dist_aggregate.c, src/aggregate/aggregate_request.c)

  • MRChannel_PopWithTimeout(chan, abstime, abortFlag, timedOut) — blocking pop with two independently-optional break conditions: wall-clock deadline and atomic abort flag. New MRChannel_WakeAbort(chan) completes the abort protocol.
  • MRIterator_NextWithTimeout / MRIterator_GetChannel — thin iterator passthrough.
  • RequestSyncCtx gains abortWakeChannel (weak pointer) + abortWakeLock and the extern helpers Register / Unregister / WakeAbortChannel. The lock protects pointer validity; Unregister blocks until any in-flight WakeAbortChannel completes.
  • Both RPNet start paths (rpnetNext_Start, rpnetNext_StartWithMappings) register the iterator's channel on creation; rpnetFree unregisters before MRIterator_Release — critical invariant for lifetime safety.
  • getNextReply passes &areq->syncCtx.timedOut as the abort flag on both pops (steady-state and WITHCOUNT barrier-wait); NULL pop distinguishes abort from EOF by re-reading AREQ_TimedOut(req) and returns RS_RESULT_TIMEDOUT on abort.
  • DistAggregateTimeoutReturnStrictClient calls RequestSyncCtx_WakeAbortChannel right after SetTimedOut so the atomic_load_explicit(memory_order_acquire) on the BG side is guaranteed to observe the flag.

Observability

Three debug-only sync points (compiled under ENABLE_ASSERT) support the race-deterministic coverage and have zero effect in release builds:

  • SYNC_POINT_BEFORE_AGGREGATE_RESULTS_CLAIM (startPipeline) — pre-claim race.
  • SYNC_POINT_BEFORE_RPNET_START (rpnetNext_Start) — post-claim / pre-dispatch race.
  • SYNC_POINT_RPNET_REPLY_ADMITTED (rpnetNext) — mid-pipeline race after a shard reply has been admitted.

The post-store race is exercised via debugPauseStoreResults (BG parks after AREQ_StoreResults and polls AREQ_TimedOut to break out).

Test coverage

tests/pytests/test_blocked_client_timeout.py — TestCoordinatorTimeout class — covers all three regions plus pipeline-shape variants:

  • Pre-claim: test_return_strict_timeout_at_claim_sync_point_aggregate.
  • In-pipeline: test_return_strict_timeout_at_rpnet_start_sync_point_aggregate, test_return_strict_timeout_channel_drain_aggregate, plus discard-class coverage in test_return_strict_timeout_sortby_one_shard_paused_aggregate (RPSorter discard) and test_return_strict_timeout_withcount_one_shard_paused_aggregate (ShardResponseBarrier and RPDepleter RETURN_STRICT discard).
  • Post-store: test_return_strict_timeout_after_store_aggregate.
  • Topology variants: one_shard_paused, all_shards_paused.
  • FAIL regression guard: test_shard_timeout_fail.

Related PRs

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

Release Notes

  • This PR requires release notes
  • This PR does not require release notes

If a release note is required (bug fix / new feature / enhancement), describe the user impact of this PR in the title.


Note

High Risk
Touches coordinator timeout/reply behavior and cross-thread synchronization (CAS/condvar/channel wake) in distributed aggregation, where mistakes can cause deadlocks, double replies, or incorrect partial results under timeout.

Overview
Coordinator FT.AGGREGATE now supports ON_TIMEOUT RETURN_STRICT on the blocked-client path: the timeout callback can take ownership of the reply, wake a potentially-blocked shard reader, wait for the background pipeline to finish storing results, and then reply with either drained partial rows (for strictly-streaming pipeline shapes) or an empty result set + timeout warning (for buffering/reordering pipelines).

This introduces a shared RequestSyncCtx handshake (CAS claim + condvar completion + abort-wake MR channel registration) used by AREQ/HybridRequest, wires RPNet/MRIterator/MRChannel to support abort-flag driven wakeups, adjusts aggregation execution/serialization to not drop stored buffered results under RETURN_STRICT, and adds extensive deterministic cluster timeout tests via new debug sync points.

Reviewed by Cursor Bugbot for commit 5f11051. Bugbot is set up for automated code reviews on this repo. Configure here.

@jit-ci

jit-ci Bot commented Apr 22, 2026 •

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@lerman25
lerman25 force-pushed the omerl-agg-coord-return-strict branch from 94a9a63 to 018020b Compare April 22, 2026 13:55
@github-actions github-actions Bot added size:L and removed size:M labels Apr 22, 2026
@lerman25 lerman25 changed the title Omerl agg coord return strict [MOD-13617] [Agg] Coordinator handle return-strict Apr 22, 2026
@lerman25
lerman25 force-pushed the omerl-agg-coord-return-strict branch from c382c6e to dfe6450 Compare April 22, 2026 15:43
@lerman25
lerman25 marked this pull request as ready for review April 22, 2026 15:43
Comment thread src/coord/rpnet.c Resolved
@codecov

codecov Bot commented Apr 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.55556% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.27%. Comparing base (07cb115) to head (5f11051).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/coord/dist_aggregate.c 90.47% 6 Missing ⚠️
src/aggregate/aggregate_exec.c 95.00% 1 Missing ⚠️
src/coord/rmr/chan.c 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9234      +/-   ##
==========================================
+ Coverage   81.22%   81.27%   +0.05%     
==========================================
  Files         487      492       +5     
  Lines       66412    66847     +435     
  Branches    23392    23562     +170     
==========================================
+ Hits        53940    54328     +388     
- Misses      12234    12280      +46     
- Partials      238      239       +1     
Flag Coverage Δ
flow 83.58% <95.55%> (+0.11%) ⬆️
unit 50.17% <7.22%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/coord/dist_aggregate.c Resolved
Comment thread src/aggregate/aggregate_exec.c Resolved
Classify the coordinator result-processor chain as trivial when it is
exactly RPNet -> RPPager_Limiter -> end (i.e. a plain query with at
most a LIMIT, no sort / group / buffering). Profile queries are
excluded because RPProfile wraps each RP.

The flag is consumed in a subsequent commit to decide whether the
RETURN-STRICT timeout callback may safely drain queued shard replies on
the main thread after the background pipeline aborts.
After a successful AREQ_TryClaimAggregateResults, re-check AREQ_TimedOut
before invoking the pipeline. Handles the narrow race where the
RETURN-STRICT timeout callback set the flag and woke the abort channel
between our CAS and the first Next() — in that case the timeout
callback is already blocked in AREQ_WaitForAggregateResultsComplete and
expects to read whatever we store. Skipping the pipeline leaves the
stored state with zero results and rc=RS_RESULT_TIMEDOUT, which the
main thread will honor.
Add a drainOnly flag on RPNet, set by the RETURN-STRICT timeout
callback on the main thread once the background pipeline has aborted
and exited. In this mode rpnetNext:

  * skips the wall-clock TimedOut check (the deadline has by
    definition already passed); and
  * treats an empty channel pop as RS_RESULT_EOF rather than
    RS_RESULT_TIMEDOUT.

MRChannel_PopWithTimeout already returns NULL immediately when the
abort flag is set and the channel is empty, so no new channel
primitive is needed - the drain loop simply keeps calling the
existing pop path until it returns EOF.

Safe as a plain bool: set by the main thread only after the
background thread is guaranteed to have exited the pipeline.
When the upstream signals RS_RESULT_TIMEDOUT during RPDepleter's
accumulation phase and the effective timeout policy is RETURN-STRICT,
return TIMEDOUT immediately instead of transitioning to the yield
phase and draining the already-buffered results.

This matches the behavior already in RPSorter,
RPMaxScoreNormalizer, and RPSafeLoader (via their
"rc != RS_RESULT_OK" fallthrough which only consumes
TimeoutPolicy_Return on the yield-transition path). RETURN-STRICT
requires a strict empty-results response on timeout for pipelines
that contain buffering result processors.
When the RETURN-STRICT timeout callback observes that the background
thread has already claimed the aggregation results, it now waits for
the background pipeline to exit (as before) and then — for pipelines
classified as trivial (`RPNet -> RPPager -> end`) — resumes the
pipeline on the main thread to harvest shard replies that were already
queued in the channel before the deadline.

The pager's internal `remaining` and `qctx->resultLimit` were both
decremented by the background's partial run, so the drain loop
naturally respects the user's LIMIT and terminates when either the
budget is exhausted or RPNet reports EOF (empty channel under
`drainOnly`).

`storedReplyState.results` may be NULL in the post-claim bail path
(background exited before allocating the results array); the drain
allocates a fresh array in that case so downstream serialization has a
valid pointer.

Non-trivial pipelines are unaffected: the drain is a no-op and the
callback continues to reply with whatever the background stored.
@lerman25
lerman25 force-pushed the omerl-agg-coord-return-strict branch from be3b485 to 1f34be5 Compare April 25, 2026 14:50
@github-actions github-actions Bot removed the size:L label Apr 25, 2026
@lerman25
lerman25 force-pushed the omerl-agg-coord-return-strict branch from 98a1094 to 06871d1 Compare April 25, 2026 20:53
Comment thread src/coord/dist_aggregate.c Resolved
@fcostaoliveira

fcostaoliveira commented Apr 25, 2026 •

Copy link
Copy Markdown
Contributor

Automated performance analysis summary

This comment was automatically generated given there is performance data available.

Environment:

  • Triggering env: circleci

Architecture: x86_64 — branch-over-branch

Deployment: oss-standalone

In summary:

  • Detected a total of 30 stable tests between versions.
  • Detected a total of 11 highly unstable benchmarks (11 baseline).
  • Latency analysis confirmed regressions in 1 of the unstable tests:
  • Detected a total of 4 improvements above the improvement water line.
  • Detected a total of 8 regressions bellow the regression water line 8.0%.

You can check a comparison in detail via the grafana link

Performance Improvements - Comparison between master and omerl-agg-coord-return-strict.

Time Period from a month ago. (environment used: oss-standalone)

Test Case Baseline master (median obs. +- std.dev) Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) % change (higher-better) Note
ftsb-10K-multivalue-numeric-json 5140 +- 2.0% (14 datapoints) 7022 36.6% IMPROVEMENT
ftsb-10K-enwiki_abstract-hashes-term-prefix 11256 +- 7.3% (20 datapoints) 12626 12.2% IMPROVEMENT
search-expire-doc-10-milliseconds 14 +- 1.6% (10 datapoints) 16 10.1% IMPROVEMENT
search-numeric-sortby 16228 +- 8.2% (20 datapoints) 17732 9.3% waterline=8.2%. IMPROVEMENT

Performance Regressions and Issues - Comparison between master and omerl-agg-coord-return-strict.

Time Period from a month ago. (environment used: oss-standalone)

Test Case Baseline master (median obs. +- std.dev) Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) % change (higher-better) Note
search-high-cardinality-negation-term-comparison_union_all_other_terms 208 +- 17.8% UNSTABLE (20 datapoints) 157.0 -24.2% UNSTABLE (baseline high variance); server: p50 latency stable; client: Latency decreased 20.9% (baseline CV=1.7%); neither server nor client side confirms regression
search-numeric 16200 +- 10.1% UNSTABLE (20 datapoints) 12370.0 -23.6% UNSTABLE (baseline high variance); server: FT.SEARCH p50 decreased 10.8% (baseline CV=19.5%); client: Latency increased 5.6% (baseline CV=4.1%); neither server nor client side confirms regression
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query-non-sortable 47 +- 26.0% UNSTABLE (20 datapoints) 36.0 -23.1% UNSTABLE (baseline high variance); server: FT.SEARCH p50 increased 5.5% (baseline CV=5.4%); client: client latency stable; neither server nor client side confirms regression
search-high-cardinality-negation-term-baseline 395 +- 17.7% UNSTABLE (20 datapoints) 304.0 -22.9% UNSTABLE (baseline high variance); server: FT.SEARCH p50 decreased 8.0% (baseline CV=19.6%); client: Latency decreased 5.7% (baseline CV=17.5%); neither server nor client side confirms regression
search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-one-indexed-field 13583 +- 5.6% (20 datapoints) 10505.0 -22.7% REGRESSION
ftsb-10K-enwiki_abstract-hashes-term-suffix 13758 +- 4.8% (20 datapoints) 10701.0 -22.2% REGRESSION
ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query 10246 +- 6.2% (20 datapoints) 8316.0 -18.8% REGRESSION
search-numeric-optimize 8847 +- 6.9% (20 datapoints) 7467.0 -15.6% REGRESSION
search-expire-doc-1000-seconds 18 +- 8.7% (13 datapoints) 15.0 -14.9% waterline=8.7%. REGRESSION
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query-non-sortable 1412 +- 14.1% UNSTABLE (20 datapoints) 1218.0 -13.7% UNSTABLE (baseline high variance); server: p50 latency stable; client: client latency stable; neither server nor client side confirms regression
search-ftsb-5200K-docs-union-iterators-q1 3.9 +- 5.2% (20 datapoints) 3.5 -11.1% REGRESSION
search-expire-numeric-field-1000-seconds 17 +- 10.9% UNSTABLE (10 datapoints) 15.0 -10.8% UNSTABLE (baseline high variance); server: p50 latency stable; client: Latency increased 6.0% (baseline CV=5.7%); neither server nor client side confirms regression
search-numeric-sortby-desc-optimize 536 +- 9.3% (20 datapoints) 484.0 -9.7% waterline=9.3%. REGRESSION
search-numeric-sortby-desc 17193 +- 7.2% (20 datapoints) 15647.0 -9.0% REGRESSION
hybrid-arxiv-titles-384-angular-rrf-text-vector 1725 +- 37.0% UNSTABLE (8 datapoints) 1592.0 -7.7% UNSTABLE (baseline high variance); server: FT.HYBRID p50 increased 19.3% (baseline CV=36.4%); client: Latency increased 7.9% (baseline CV=28.0%); only server side confirms regression (client side stable) - insufficient evidence
hybrid-arxiv-titles-384-angular-linear-numeric-vector 1695 +- 32.8% UNSTABLE (8 datapoints) 1581.0 -6.7% UNSTABLE (baseline high variance); server: FT.HYBRID p50 increased 16.5% (baseline CV=35.7%); client: Latency increased 11.1% (baseline CV=26.8%); confidence=LOW (FT.HYBRID baseline CV=20.4%; FT.HYBRID p99 +9.0% (stable baseline, minor change); CV=coefficient of variation (data stability: <30% stable, 30-50% moderate, >50% unstable))
hybrid-arxiv-titles-384-angular-rrf-tag-range 4.6 +- 40.5% UNSTABLE (8 datapoints) 4.5 -3.0% UNSTABLE (baseline high variance); server: p50 latency stable; client: client latency stable; neither server nor client side confirms regression
hybrid-arxiv-titles-384-angular-linear-text-range 4.1 +- 20.4% UNSTABLE (8 datapoints) 4.2 1.7% UNSTABLE (baseline high variance); server: p50 latency stable; client: client latency stable; neither server nor client side confirms regression
search-ftsb-1M-enwiki_abstract-hashes-gc 138 +- 20.4% UNSTABLE (20 datapoints) 180.0 30.1% UNSTABLE (baseline high variance); server: hset p50 increased 12.4% (baseline CV=9.7%); client: Latency decreased 23.4% (baseline CV=16.9%); only server side confirms regression (client side stable) - insufficient evidence
Tests with No Significant Changes (30 tests)

Tests with No Significant Changes

Test Case Baseline master (median obs. +- std.dev) Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) % change (higher-better) Note
ftsb-10K-enwiki_abstract-hashes-fulltext-sortby 1557 +- 4.4% (20 datapoints) 1518.0 -2.5% No Change
ftsb-10K-enwiki_abstract-hashes-term-suffix-withsuffixtrie 16128 +- 4.3% (20 datapoints) 16553.0 2.6% No Change
ftsb-10K-enwiki_abstract-hashes-term-wildcard 13760 +- 6.5% (20 datapoints) 14634.0 6.4% potential IMPROVEMENT
ftsb-10K-enwiki_pages-hashes-fulltext-mixed_simple-1word-query_write_1_to_read_20.yml 1695 +- 6.5% (20 datapoints) 1648.0 -2.7% No Change
ftsb-10K-enwiki_pages-hashes-load 65715 +- 8.4% (20 datapoints) 66754.0 1.6% waterline=8.4%. No Change
ftsb-10K-singlevalue-numeric-json 3006 +- 1.8% (14 datapoints) 3033.0 0.9% No Change
ftsb-1K-enwiki_abstract-hashes-term-contains 11183 +- 2.5% (20 datapoints) 11374.0 1.7% No Change
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query 5570 +- 6.5% (20 datapoints) 5614.0 0.8% No Change
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query 11559 +- 6.4% (20 datapoints) 11914.0 3.1% potential IMPROVEMENT
ftsb-1M-enwiki_abstract-hashes-load 24900 +- 5.7% (20 datapoints) 24638.0 -1.1% No Change
ftsb-1M-nyc_taxis-ftadd-load 33695 +- 5.7% (20 datapoints) 35823.0 6.3% potential IMPROVEMENT
ftsb-1M-nyc_taxis-hashes-load 34347 +- 4.1% (20 datapoints) 34527.0 0.5% No Change
search-aggregate-post-filter-simple.yml 17833 +- 5.0% (20 datapoints) 19172.0 7.5% potential IMPROVEMENT
search-expire-numeric-field-10-milliseconds 16 +- 7.5% (10 datapoints) 15.0 -5.9% potential REGRESSION
search-filtering-tag-numeric 3942 +- 8.5% (20 datapoints) 3728.0 -5.4% waterline=8.5%. potential REGRESSION
search-filtering-tag-numeric-filter-pipeline 11643 +- 5.0% (20 datapoints) 12085.0 3.8% potential IMPROVEMENT
search-ftsb-10K-enwiki_abstract-hashes-fulltext-aggregate-sortby-limit-0-100 5702 +- 4.4% (20 datapoints) 6008.0 5.4% potential IMPROVEMENT
search-ftsb-10K-enwiki_abstract-hashes-fulltext-search-sortby-limit-0-100 5646 +- 4.4% (20 datapoints) 5863.0 3.8% potential IMPROVEMENT
search-ftsb-10K-enwiki_abstract-hashes-term-withoutsuffix-trie 13621 +- 4.8% (20 datapoints) 14304.0 5.0% potential IMPROVEMENT
search-ftsb-10K-enwiki_abstract-hashes-term-withsuffix-trie 13284 +- 7.4% (20 datapoints) 14214.0 7.0% potential IMPROVEMENT
search-ftsb-1700K-docs-union-iterators-q3 36 +- 5.5% (20 datapoints) 36.0 -1.3% No Change
search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-non-sortable 179 +- 8.4% (20 datapoints) 179.0 0.0% waterline=8.4%. No Change
search-ftsb-370K-docs-union-iterators-q4 37 +- 4.8% (20 datapoints) 35.0 -4.7% potential REGRESSION
search-ftsb-5500K-docs-union-iterators-q2 5.4 +- 1.9% (14 datapoints) 5.4 1.2% No Change
search-ftsb-arxiv-titles-384-angular-filters-m16-ef-128-json-load 4903 +- 7.2% (20 datapoints) 5053.0 3.1% potential IMPROVEMENT
search-geo 2698 +- 4.8% (14 datapoints) 2657.0 -1.5% No Change
search-numeric-sortby-optimize 503 +- 9.1% (20 datapoints) 484.0 -3.6% waterline=9.1%. potential REGRESSION
vecsim-arxiv-titles-384-angular-filters-m16-ef-128-fulltext-filter 7402 +- 2.7% (20 datapoints) 7389.0 -0.2% No Change
vecsim-arxiv-titles-384-angular-filters-m16-ef-128-numeric-filter 2622 +- 4.5% (20 datapoints) 2777.0 5.9% potential IMPROVEMENT
vecsim-arxiv-titles-384-angular-filters-m16-ef-128-tag-filter 15805 +- 6.1% (20 datapoints) 15816.0 0.1% No Change

Architecture: aarch64 — branch-over-branch

Deployment: oss-standalone

In summary:

  • Detected a total of 44 stable tests between versions.
  • Detected a total of 2 highly unstable benchmarks (2 baseline).

You can check a comparison in detail via the grafana link

Performance Regressions and Issues - Comparison between master and omerl-agg-coord-return-strict.

Time Period from a month ago. (environment used: oss-standalone)

Test Case Baseline master (median obs. +- std.dev) Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) % change (higher-better) Note
search-ftsb-1M-enwiki_abstract-hashes-gc 126 +- 13.0% UNSTABLE (14 datapoints) 116 -8.2% UNSTABLE (baseline high variance); server: hset p50 increased 21.7% (baseline CV=12.3%); client: Latency increased 9.3% (baseline CV=12.8%); only server side confirms regression (client side stable) - insufficient evidence
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query-non-sortable 35 +- 29.4% UNSTABLE (14 datapoints) 36 4.2% UNSTABLE (baseline high variance); server: p50 latency stable; client: client latency stable; neither server nor client side confirms regression
Tests with No Significant Changes (44 tests)

Tests with No Significant Changes

Test Case Baseline master (median obs. +- std.dev) Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) % change (higher-better) Note
ftsb-10K-enwiki_abstract-hashes-fulltext-sortby 1137 +- 3.6% (14 datapoints) 1142.0 0.4% No Change
ftsb-10K-enwiki_abstract-hashes-term-prefix 9517 +- 2.1% (14 datapoints) 9655.0 1.4% No Change
ftsb-10K-enwiki_abstract-hashes-term-suffix 10725 +- 1.5% (14 datapoints) 10701.0 -0.2% No Change
ftsb-10K-enwiki_abstract-hashes-term-suffix-withsuffixtrie 11569 +- 0.7% (14 datapoints) 11441.0 -1.1% No Change
ftsb-10K-enwiki_abstract-hashes-term-wildcard 10872 +- 1.6% (14 datapoints) 10851.0 -0.2% No Change
ftsb-10K-enwiki_pages-hashes-fulltext-mixed_simple-1word-query_write_1_to_read_20.yml 1620 +- 2.4% (14 datapoints) 1648.0 1.7% No Change
ftsb-10K-enwiki_pages-hashes-load 57565 +- 4.3% (14 datapoints) 61929.0 7.6% potential IMPROVEMENT
ftsb-10K-multivalue-numeric-json 5140 +- 2.0% (14 datapoints) 5071.0 -1.4% No Change
ftsb-10K-singlevalue-numeric-json 3006 +- 1.8% (14 datapoints) 3033.0 0.9% No Change
ftsb-1K-enwiki_abstract-hashes-term-contains 9116 +- 1.5% (14 datapoints) 9222.0 1.2% No Change
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query 4340 +- 4.8% (14 datapoints) 4479.0 3.2% potential IMPROVEMENT
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query 9542 +- 1.7% (14 datapoints) 9613.0 0.7% No Change
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query-non-sortable 1225 +- 7.7% (14 datapoints) 1218.0 -0.6% No Change
ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query 8111 +- 2.8% (14 datapoints) 8316.0 2.5% No Change
ftsb-1M-enwiki_abstract-hashes-load 22660 +- 3.6% (14 datapoints) 23276.0 2.7% No Change
ftsb-1M-nyc_taxis-ftadd-load 26106 +- 2.9% (14 datapoints) 26927.0 3.1% potential IMPROVEMENT
ftsb-1M-nyc_taxis-hashes-load 27402 +- 2.5% (14 datapoints) 27728.0 1.2% No Change
search-aggregate-post-filter-simple.yml 12600 +- 1.2% (14 datapoints) 12652.0 0.4% No Change
search-expire-doc-10-milliseconds 14 +- 1.6% (10 datapoints) 14.0 -2.1% No Change
search-expire-doc-1000-seconds 14 +- 2.5% (10 datapoints) 14.0 0.6% No Change
search-expire-numeric-field-10-milliseconds 14 +- 3.2% (10 datapoints) 15.0 2.6% No Change
search-expire-numeric-field-1000-seconds 14 +- 1.9% (10 datapoints) 14.0 -3.9% potential REGRESSION
search-filtering-tag-numeric 3521 +- 9.5% (14 datapoints) 3653.0 3.8% waterline=9.5%. potential IMPROVEMENT
search-filtering-tag-numeric-filter-pipeline 9305 +- 1.1% (14 datapoints) 9316.0 0.1% No Change
search-ftsb-10K-enwiki_abstract-hashes-fulltext-aggregate-sortby-limit-0-100 4952 +- 1.4% (14 datapoints) 5016.0 1.3% No Change
search-ftsb-10K-enwiki_abstract-hashes-fulltext-search-sortby-limit-0-100 4922 +- 2.8% (14 datapoints) 4969.0 0.9% No Change
search-ftsb-10K-enwiki_abstract-hashes-term-withoutsuffix-trie 10332 +- 1.1% (14 datapoints) 10561.0 2.2% No Change
search-ftsb-10K-enwiki_abstract-hashes-term-withsuffix-trie 10315 +- 0.9% (14 datapoints) 10442.0 1.2% No Change
search-ftsb-1700K-docs-union-iterators-q3 32 +- 1.2% (14 datapoints) 32.0 -1.2% No Change
search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-non-sortable 164 +- 5.1% (14 datapoints) 173.0 5.4% potential IMPROVEMENT
search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-one-indexed-field 10366 +- 1.6% (14 datapoints) 10505.0 1.3% No Change
search-ftsb-370K-docs-union-iterators-q4 33 +- 1.0% (14 datapoints) 33.0 -1.2% No Change
search-ftsb-5200K-docs-union-iterators-q1 3.5 +- 1.8% (14 datapoints) 3.5 -1.4% No Change
search-ftsb-5500K-docs-union-iterators-q2 5.4 +- 1.9% (14 datapoints) 5.4 1.2% No Change
search-ftsb-arxiv-titles-384-angular-filters-m16-ef-128-json-load 3659 +- 5.4% (14 datapoints) 3563.0 -2.6% No Change
search-geo 2698 +- 4.8% (14 datapoints) 2657.0 -1.5% No Change
search-high-cardinality-negation-term-baseline 309 +- 1.2% (14 datapoints) 304.0 -1.6% No Change
search-high-cardinality-negation-term-comparison_union_all_other_terms 159 +- 1.8% (14 datapoints) 157.0 -0.9% No Change
search-numeric 13062 +- 4.0% (14 datapoints) 12370.0 -5.3% potential REGRESSION
search-numeric-optimize 7414 +- 0.8% (14 datapoints) 7467.0 0.7% No Change
search-numeric-sortby 12495 +- 3.5% (14 datapoints) 12063.0 -3.5% potential REGRESSION
search-numeric-sortby-desc 12228 +- 4.2% (14 datapoints) 12973.0 6.1% potential IMPROVEMENT
search-numeric-sortby-desc-optimize 482 +- 5.9% (14 datapoints) 482.0 -0.1% No Change
search-numeric-sortby-optimize 475 +- 6.3% (14 datapoints) 484.0 2.0% No Change

Cross-arch delta on omerl-agg-coord-return-strict (x86_64 → aarch64)

Same commit (omerl-agg-coord-return-strict) compared across architectures. Positive deltas = aarch64 outperforms x86_64.

In summary:

You can check a comparison in detail via the grafana link

Performance Regressions and Issues - Comparison between omerl-agg-coord-return-strict and omerl-agg-coord-return-strict.

Time Period from a month ago. (environment used: oss-standalone)

Test Case Baseline omerl-agg-coord-return-strict (median obs. +- std.dev) Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) % change (higher-better) Note
search-aggregate-post-filter-simple.yml 17650 +- 9.3% (10 datapoints) 12652 -28.3% waterline=9.3%. REGRESSION
search-ftsb-arxiv-titles-384-angular-filters-m16-ef-128-json-load 4915 +- 10.4% UNSTABLE (10 datapoints) 3563 -27.5% UNSTABLE (baseline high variance); server: json.set p50 increased 36.2% (baseline CV=10.7%); client: OverallQuantiles.allCommands.q50 increased 39.5% (baseline CV=11.3%); confidence=HIGH (json.set baseline CV=9.4%; json.set p99 +23.9% (stable baseline); CV=coefficient of variation (data stability: <30% stable, 30-50% moderate, >50% unstable))
ftsb-10K-enwiki_abstract-hashes-term-suffix-withsuffixtrie 15509 +- 7.1% (10 datapoints) 11441 -26.2% REGRESSION
ftsb-10K-multivalue-numeric-json 6760 +- 10.0% UNSTABLE (10 datapoints) 5071 -25.0% UNSTABLE (baseline high variance); server: FT.SEARCH p50 increased 49.0% (baseline CV=13.6%); client: OverallQuantiles.allCommands.q50 increased 38.5% (baseline CV=11.7%); confidence=HIGH (FT.SEARCH baseline CV=8.5%; FT.SEARCH p99 +23.6% (stable baseline); CV=coefficient of variation (data stability: <30% stable, 30-50% moderate, >50% unstable))
search-numeric-sortby 16056 +- 10.9% UNSTABLE (10 datapoints) 12063 -24.9% UNSTABLE (baseline high variance); server: FT.SEARCH p50 increased 56.6% (baseline CV=18.2%); client: client latency stable; only server side confirms regression (client side stable) - insufficient evidence
ftsb-10K-enwiki_abstract-hashes-fulltext-sortby 1517 +- 2.6% (10 datapoints) 1142 -24.7% REGRESSION
search-ftsb-1M-enwiki_abstract-hashes-gc 151 +- 17.9% UNSTABLE (10 datapoints) 116 -23.1% UNSTABLE (baseline high variance); server: hset p50 increased 55.3% (baseline CV=11.3%); client: Latency increased 30.2% (baseline CV=18.0%); confidence=LOW (hset baseline CV=5.7%; hset p99 0.0% (stable baseline, minor change); CV=coefficient of variation (data stability: <30% stable, 30-50% moderate, >50% unstable))
search-ftsb-10K-enwiki_abstract-hashes-term-withsuffix-trie 13367 +- 7.9% (10 datapoints) 10442 -21.9% REGRESSION
ftsb-10K-enwiki_abstract-hashes-term-wildcard 13805 +- 6.9% (10 datapoints) 10851 -21.4% REGRESSION
search-ftsb-10K-enwiki_abstract-hashes-term-withoutsuffix-trie 13439 +- 10.4% UNSTABLE (10 datapoints) 10561 -21.4% UNSTABLE (baseline high variance); server: FT.SEARCH p50 decreased 20.0% (baseline CV=27.4%); client: Latency increased 50.0% (baseline CV=16.6%); only client side confirms regression (server side stable) - insufficient evidence
search-numeric-sortby-desc 16491 +- 7.7% (10 datapoints) 12973 -21.3% REGRESSION
ftsb-1M-nyc_taxis-hashes-load 34459 +- 6.3% (10 datapoints) 27728 -19.5% REGRESSION
ftsb-1M-nyc_taxis-ftadd-load 33363 +- 8.8% (10 datapoints) 26927 -19.3% waterline=8.8%. REGRESSION
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query 5435 +- 4.7% (10 datapoints) 4479 -17.6% REGRESSION
ftsb-1K-enwiki_abstract-hashes-term-contains 11138 +- 4.4% (10 datapoints) 9222 -17.2% REGRESSION
search-filtering-tag-numeric-filter-pipeline 11248 +- 10.3% UNSTABLE (11 datapoints) 9316 -17.2% UNSTABLE (baseline high variance); server: FT.AGGREGATE p50 decreased 30.0% (baseline CV=20.5%); client: client latency stable; neither server nor client side confirms regression
ftsb-10K-enwiki_abstract-hashes-term-prefix 11613 +- 8.4% (10 datapoints) 9655 -16.9% waterline=8.4%. REGRESSION
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query 11452 +- 6.5% (10 datapoints) 9613 -16.1% REGRESSION
search-ftsb-10K-enwiki_abstract-hashes-fulltext-aggregate-sortby-limit-0-100 5663 +- 7.8% (10 datapoints) 5016 -11.4% REGRESSION
search-expire-doc-10-milliseconds 16 +- 9.3% (5 datapoints) 14 -11.1% waterline=9.3%. REGRESSION
search-ftsb-10K-enwiki_abstract-hashes-fulltext-search-sortby-limit-0-100 5563 +- 7.2% (10 datapoints) 4969 -10.7% REGRESSION
search-expire-numeric-field-1000-seconds 15 +- 8.2% (5 datapoints) 14 -9.6% waterline=8.2%. REGRESSION
search-expire-doc-1000-seconds 16 +- 7.1% (5 datapoints) 14 -8.5% REGRESSION
search-ftsb-1700K-docs-union-iterators-q3 35 +- 4.8% (11 datapoints) 32 -8.3% REGRESSION
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query-non-sortable 36 +- 22.3% UNSTABLE (5 datapoints) 36 0.0% UNSTABLE (baseline high variance); server: p50 latency stable; client: client latency stable; neither server nor client side confirms regression
Tests with No Significant Changes (21 tests)

Tests with No Significant Changes

Test Case Baseline omerl-agg-coord-return-strict (median obs. +- std.dev) Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) % change (higher-better) Note
ftsb-10K-enwiki_abstract-hashes-term-suffix 10707 +- 1.1% (5 datapoints) 10701.0 -0.1% No Change
ftsb-10K-enwiki_pages-hashes-fulltext-mixed_simple-1word-query_write_1_to_read_20.yml 1569 +- 4.2% (5 datapoints) 1648.0 5.0% potential IMPROVEMENT
ftsb-10K-enwiki_pages-hashes-load 66534 +- 7.1% (10 datapoints) 61929.0 -6.9% potential REGRESSION
ftsb-10K-singlevalue-numeric-json 3007 +- 1.3% (5 datapoints) 3033.0 0.9% No Change
ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query-non-sortable 1218 +- 5.1% (5 datapoints) 1218.0 0.0%
ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query 7896 +- 4.4% (5 datapoints) 8316.0 5.3% potential IMPROVEMENT
ftsb-1M-enwiki_abstract-hashes-load 23715 +- 6.6% (10 datapoints) 23276.0 -1.9% No Change
search-expire-numeric-field-10-milliseconds 14 +- 2.4% (5 datapoints) 15.0 3.9% potential IMPROVEMENT
search-filtering-tag-numeric 3729 +- 8.8% (11 datapoints) 3653.0 -2.0% waterline=8.8%. No Change
search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-non-sortable 169 +- 9.3% (10 datapoints) 173.0 2.1% waterline=9.3%. No Change
search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-one-indexed-field 10402 +- 1.4% (5 datapoints) 10505.0 1.0% No Change
search-ftsb-370K-docs-union-iterators-q4 35 +- 1.2% (10 datapoints) 33.0 -6.2% potential REGRESSION
search-ftsb-5200K-docs-union-iterators-q1 3.5 +- 0.8% (5 datapoints) 3.5 -1.4% No Change
search-ftsb-5500K-docs-union-iterators-q2 5.4 +- 1.6% (5 datapoints) 5.4 -0.2% No Change
search-geo 2622 +- 2.2% (5 datapoints) 2657.0 1.3% No Change
search-high-cardinality-negation-term-baseline 296 +- 1.4% (5 datapoints) 304.0 2.6% No Change
search-high-cardinality-negation-term-comparison_union_all_other_terms 156 +- 1.0% (5 datapoints) 157.0 1.0% No Change
search-numeric 12920 +- 3.7% (5 datapoints) 12370.0 -4.3% potential REGRESSION
search-numeric-optimize 7430 +- 0.6% (5 datapoints) 7467.0 0.5% No Change
search-numeric-sortby-desc-optimize 510 +- 7.2% (10 datapoints) 482.0 -5.5% potential REGRESSION
search-numeric-sortby-optimize 468 +- 6.8% (5 datapoints) 484.0 3.6% potential IMPROVEMENT

Comment thread src/coord/rmr/chan.c
if (!abstimeMono) {
return MRChannel_Pop(chan);
}
void *MRChannel_PopWithTimeout(MRChannel *chan, const struct timespec *abstimeMono,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider asserting the pointers are not NULL, if we don't need this variants

Comment thread src/coord/rmr/chan.c Outdated
return NULL;
}
} else {
pthread_cond_wait(&chan->cond, &chan->lock);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant (we have MRChannel_Pop for that)

Comment thread src/coord/dist_aggregate.c Outdated
Comment on lines +252 to +253
qctx->endProc && qctx->endProc->type == RP_PAGER_LIMITER &&
qctx->endProc->upstream == qctx->rootProc;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make it clear that the cases we handle are

  1. last is pager, and its upstream is the RPNet
  2. The last is the RPNet

return;
}

RPNet *rpnet = (RPNet *)qctx->rootProc;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider asserting the type

Comment thread src/result_processor.h Outdated
// Set post-construction on the coordinator AREQ. Used by the RETURN-STRICT
// timeout path to drain queued shard replies on the main thread after the
// background pipeline has aborted.
bool yieldsPartialResults;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming "canYield...` or something similar

Comment thread src/result_processor.c Outdated
Comment on lines +2721 to +2722
if (self->last_rc == RS_RESULT_TIMEDOUT &&
base->parent->timeoutPolicy == TimeoutPolicy_ReturnStrict) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't fail behave the same way?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUG, will backport the fix

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 84f5c97. Configure here.

Comment thread src/coord/dist_aggregate.c Resolved
GuyAv46
GuyAv46 previously approved these changes Apr 29, 2026
Comment thread src/debug_commands.h Outdated
Comment on lines +108 to +112
#define SYNC_POINT_AFTER_ITERATOR_CREATE "AfterIteratorCreate"
#define SYNC_POINT_BEFORE_FIRST_READ "BeforeFirstRead"
#define SYNC_POINT_BEFORE_DIST_HYBRID_PROMOTE "BeforeDistHybridPromote"
#define SYNC_POINT_BEFORE_SPEC_LOCK "BeforeSpecLock"
#define SYNC_POINT_BEFORE_CURSOR_READ_SEND_CHUNK "BeforeCursorReadSendChunk"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format is broken

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
22.3% Duplication on New Code (required ≤ 3%)
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@lerman25
lerman25 added this pull request to the merge queue Apr 29, 2026
Merged via the queue into master with commit d47c6d5 Apr 29, 2026
98 of 99 checks passed
@lerman25
lerman25 deleted the omerl-agg-coord-return-strict branch April 29, 2026 16:34
lerman25 added a commit that referenced this pull request Apr 29, 2026
RPSorter (rpsortNext_innerLoop) now handles all three timeout policies
explicitly:
  - FAIL: propagate TIMEDOUT in O(1) (no yield transition).
  - RETURN: existing behavior (switch to yield, surface buffered rows).
  - RETURN_STRICT: switch to yield (so the main-thread drain can pop the
    buffered, sorted prefix) and propagate TIMEDOUT immediately so the BG
    abort path is not delayed by per-row yields.

pipelineCanYieldPartialResults is consolidated from a per-shape boolean
enumeration to a peel chain: optional RPPager_Limiter, optional RPSorter,
then RPNet root. Adds the two SORTBY shapes (RPSorter -> RPNet and
RPPager_Limiter -> RPSorter -> RPNet) without changing behavior for the
shapes already supported in #9234.

Adds three pytest cases mirroring the trivial-pipeline coverage:
SORTBY one-shard-paused (sync-pointed for exact partial count),
all-shards-paused, and post-store.
pull Bot pushed a commit to Mu-L/RediSearch that referenced this pull request May 4, 2026
…o SORTBY pipelines (RediSearch#9366)

* Setup callback and mechanism

* Implement Abort Channel Pop + Use

(cherry picked from commit 94a9a63)

* Add test for no-tail Case

* Expand

* Cover before RPNET

* Remove timeout check from RETURN polcy

* refactor comments

* Reset claim of aggregate results

* Make test more accurate and robust

* Add isTrivialPipeline classifier on coordinator

Classify the coordinator result-processor chain as trivial when it is
exactly RPNet -> RPPager_Limiter -> end (i.e. a plain query with at
most a LIMIT, no sort / group / buffering). Profile queries are
excluded because RPProfile wraps each RP.

The flag is consumed in a subsequent commit to decide whether the
RETURN-STRICT timeout callback may safely drain queued shard replies on
the main thread after the background pipeline aborts.

* startPipeline: bail post-claim when already timed out

After a successful AREQ_TryClaimAggregateResults, re-check AREQ_TimedOut
before invoking the pipeline. Handles the narrow race where the
RETURN-STRICT timeout callback set the flag and woke the abort channel
between our CAS and the first Next() — in that case the timeout
callback is already blocked in AREQ_WaitForAggregateResultsComplete and
expects to read whatever we store. Skipping the pipeline leaves the
stored state with zero results and rc=RS_RESULT_TIMEDOUT, which the
main thread will honor.

* Add drainOnly mode to RPNet

Add a drainOnly flag on RPNet, set by the RETURN-STRICT timeout
callback on the main thread once the background pipeline has aborted
and exited. In this mode rpnetNext:

  * skips the wall-clock TimedOut check (the deadline has by
    definition already passed); and
  * treats an empty channel pop as RS_RESULT_EOF rather than
    RS_RESULT_TIMEDOUT.

MRChannel_PopWithTimeout already returns NULL immediately when the
abort flag is set and the channel is empty, so no new channel
primitive is needed - the drain loop simply keeps calling the
existing pop path until it returns EOF.

Safe as a plain bool: set by the main thread only after the
background thread is guaranteed to have exited the pipeline.

* RPDepleter: O(1) TIMEDOUT abort under RETURN-STRICT

When the upstream signals RS_RESULT_TIMEDOUT during RPDepleter's
accumulation phase and the effective timeout policy is RETURN-STRICT,
return TIMEDOUT immediately instead of transitioning to the yield
phase and draining the already-buffered results.

This matches the behavior already in RPSorter,
RPMaxScoreNormalizer, and RPSafeLoader (via their
"rc != RS_RESULT_OK" fallthrough which only consumes
TimeoutPolicy_Return on the yield-transition path). RETURN-STRICT
requires a strict empty-results response on timeout for pipelines
that contain buffering result processors.

* Coordinator: drain trivial pipelines on main after timeout

When the RETURN-STRICT timeout callback observes that the background
thread has already claimed the aggregation results, it now waits for
the background pipeline to exit (as before) and then — for pipelines
classified as trivial (`RPNet -> RPPager -> end`) — resumes the
pipeline on the main thread to harvest shard replies that were already
queued in the channel before the deadline.

The pager's internal `remaining` and `qctx->resultLimit` were both
decremented by the background's partial run, so the drain loop
naturally respects the user's LIMIT and terminates when either the
budget is exhausted or RPNet reports EOF (empty channel under
`drainOnly`).

`storedReplyState.results` may be NULL in the post-claim bail path
(background exited before allocating the results array); the drain
allocates a fresh array in that case so downstream serialization has a
valid pointer.

Non-trivial pipelines are unaffected: the drain is a no-op and the
callback continues to reply with whatever the background stored.

* Improve + Tests

* cursor comment

* Improve

* More fixes

* Review comment fixes

* Use the new SyncPointfunctionality

* Fix no results

* Fix format

* MOD-13617: extend RETURN_STRICT partial results to SORTBY pipelines

RPSorter (rpsortNext_innerLoop) now handles all three timeout policies
explicitly:
  - FAIL: propagate TIMEDOUT in O(1) (no yield transition).
  - RETURN: existing behavior (switch to yield, surface buffered rows).
  - RETURN_STRICT: switch to yield (so the main-thread drain can pop the
    buffered, sorted prefix) and propagate TIMEDOUT immediately so the BG
    abort path is not delayed by per-row yields.

pipelineCanYieldPartialResults is consolidated from a per-shape boolean
enumeration to a peel chain: optional RPPager_Limiter, optional RPSorter,
then RPNet root. Adds the two SORTBY shapes (RPSorter -> RPNet and
RPPager_Limiter -> RPSorter -> RPNet) without changing behavior for the
shapes already supported in RediSearch#9234.

Adds three pytest cases mirroring the trivial-pipeline coverage:
SORTBY one-shard-paused (sync-pointed for exact partial count),
all-shards-paused, and post-store.

* MOD-13617: WIP add APPLY+SORTBY tests for partial results

* Update tests

* Merge

* Shorten Comments

* Fix
pierrelambert pushed a commit to pierrelambert/RediSearch that referenced this pull request May 13, 2026
* Setup callback and mechanism

* Implement Abort Channel Pop + Use

(cherry picked from commit 94a9a63)

* Add test for no-tail Case

* Expand

* Cover before RPNET

* Remove timeout check from RETURN polcy

* refactor comments

* Reset claim of aggregate results

* Make test more accurate and robust

* Add isTrivialPipeline classifier on coordinator

Classify the coordinator result-processor chain as trivial when it is
exactly RPNet -> RPPager_Limiter -> end (i.e. a plain query with at
most a LIMIT, no sort / group / buffering). Profile queries are
excluded because RPProfile wraps each RP.

The flag is consumed in a subsequent commit to decide whether the
RETURN-STRICT timeout callback may safely drain queued shard replies on
the main thread after the background pipeline aborts.

* startPipeline: bail post-claim when already timed out

After a successful AREQ_TryClaimAggregateResults, re-check AREQ_TimedOut
before invoking the pipeline. Handles the narrow race where the
RETURN-STRICT timeout callback set the flag and woke the abort channel
between our CAS and the first Next() — in that case the timeout
callback is already blocked in AREQ_WaitForAggregateResultsComplete and
expects to read whatever we store. Skipping the pipeline leaves the
stored state with zero results and rc=RS_RESULT_TIMEDOUT, which the
main thread will honor.

* Add drainOnly mode to RPNet

Add a drainOnly flag on RPNet, set by the RETURN-STRICT timeout
callback on the main thread once the background pipeline has aborted
and exited. In this mode rpnetNext:

  * skips the wall-clock TimedOut check (the deadline has by
    definition already passed); and
  * treats an empty channel pop as RS_RESULT_EOF rather than
    RS_RESULT_TIMEDOUT.

MRChannel_PopWithTimeout already returns NULL immediately when the
abort flag is set and the channel is empty, so no new channel
primitive is needed - the drain loop simply keeps calling the
existing pop path until it returns EOF.

Safe as a plain bool: set by the main thread only after the
background thread is guaranteed to have exited the pipeline.

* RPDepleter: O(1) TIMEDOUT abort under RETURN-STRICT

When the upstream signals RS_RESULT_TIMEDOUT during RPDepleter's
accumulation phase and the effective timeout policy is RETURN-STRICT,
return TIMEDOUT immediately instead of transitioning to the yield
phase and draining the already-buffered results.

This matches the behavior already in RPSorter,
RPMaxScoreNormalizer, and RPSafeLoader (via their
"rc != RS_RESULT_OK" fallthrough which only consumes
TimeoutPolicy_Return on the yield-transition path). RETURN-STRICT
requires a strict empty-results response on timeout for pipelines
that contain buffering result processors.

* Coordinator: drain trivial pipelines on main after timeout

When the RETURN-STRICT timeout callback observes that the background
thread has already claimed the aggregation results, it now waits for
the background pipeline to exit (as before) and then — for pipelines
classified as trivial (`RPNet -> RPPager -> end`) — resumes the
pipeline on the main thread to harvest shard replies that were already
queued in the channel before the deadline.

The pager's internal `remaining` and `qctx->resultLimit` were both
decremented by the background's partial run, so the drain loop
naturally respects the user's LIMIT and terminates when either the
budget is exhausted or RPNet reports EOF (empty channel under
`drainOnly`).

`storedReplyState.results` may be NULL in the post-claim bail path
(background exited before allocating the results array); the drain
allocates a fresh array in that case so downstream serialization has a
valid pointer.

Non-trivial pipelines are unaffected: the drain is a no-op and the
callback continues to reply with whatever the background stored.

* Improve + Tests

* cursor comment

* Improve

* More fixes

* Review comment fixes

* Use the new SyncPointfunctionality

* Fix no results

* Fix format
pierrelambert pushed a commit to pierrelambert/RediSearch that referenced this pull request May 13, 2026
…o SORTBY pipelines (RediSearch#9366)

* Setup callback and mechanism

* Implement Abort Channel Pop + Use

(cherry picked from commit 94a9a63)

* Add test for no-tail Case

* Expand

* Cover before RPNET

* Remove timeout check from RETURN polcy

* refactor comments

* Reset claim of aggregate results

* Make test more accurate and robust

* Add isTrivialPipeline classifier on coordinator

Classify the coordinator result-processor chain as trivial when it is
exactly RPNet -> RPPager_Limiter -> end (i.e. a plain query with at
most a LIMIT, no sort / group / buffering). Profile queries are
excluded because RPProfile wraps each RP.

The flag is consumed in a subsequent commit to decide whether the
RETURN-STRICT timeout callback may safely drain queued shard replies on
the main thread after the background pipeline aborts.

* startPipeline: bail post-claim when already timed out

After a successful AREQ_TryClaimAggregateResults, re-check AREQ_TimedOut
before invoking the pipeline. Handles the narrow race where the
RETURN-STRICT timeout callback set the flag and woke the abort channel
between our CAS and the first Next() — in that case the timeout
callback is already blocked in AREQ_WaitForAggregateResultsComplete and
expects to read whatever we store. Skipping the pipeline leaves the
stored state with zero results and rc=RS_RESULT_TIMEDOUT, which the
main thread will honor.

* Add drainOnly mode to RPNet

Add a drainOnly flag on RPNet, set by the RETURN-STRICT timeout
callback on the main thread once the background pipeline has aborted
and exited. In this mode rpnetNext:

  * skips the wall-clock TimedOut check (the deadline has by
    definition already passed); and
  * treats an empty channel pop as RS_RESULT_EOF rather than
    RS_RESULT_TIMEDOUT.

MRChannel_PopWithTimeout already returns NULL immediately when the
abort flag is set and the channel is empty, so no new channel
primitive is needed - the drain loop simply keeps calling the
existing pop path until it returns EOF.

Safe as a plain bool: set by the main thread only after the
background thread is guaranteed to have exited the pipeline.

* RPDepleter: O(1) TIMEDOUT abort under RETURN-STRICT

When the upstream signals RS_RESULT_TIMEDOUT during RPDepleter's
accumulation phase and the effective timeout policy is RETURN-STRICT,
return TIMEDOUT immediately instead of transitioning to the yield
phase and draining the already-buffered results.

This matches the behavior already in RPSorter,
RPMaxScoreNormalizer, and RPSafeLoader (via their
"rc != RS_RESULT_OK" fallthrough which only consumes
TimeoutPolicy_Return on the yield-transition path). RETURN-STRICT
requires a strict empty-results response on timeout for pipelines
that contain buffering result processors.

* Coordinator: drain trivial pipelines on main after timeout

When the RETURN-STRICT timeout callback observes that the background
thread has already claimed the aggregation results, it now waits for
the background pipeline to exit (as before) and then — for pipelines
classified as trivial (`RPNet -> RPPager -> end`) — resumes the
pipeline on the main thread to harvest shard replies that were already
queued in the channel before the deadline.

The pager's internal `remaining` and `qctx->resultLimit` were both
decremented by the background's partial run, so the drain loop
naturally respects the user's LIMIT and terminates when either the
budget is exhausted or RPNet reports EOF (empty channel under
`drainOnly`).

`storedReplyState.results` may be NULL in the post-claim bail path
(background exited before allocating the results array); the drain
allocates a fresh array in that case so downstream serialization has a
valid pointer.

Non-trivial pipelines are unaffected: the drain is a no-op and the
callback continues to reply with whatever the background stored.

* Improve + Tests

* cursor comment

* Improve

* More fixes

* Review comment fixes

* Use the new SyncPointfunctionality

* Fix no results

* Fix format

* MOD-13617: extend RETURN_STRICT partial results to SORTBY pipelines

RPSorter (rpsortNext_innerLoop) now handles all three timeout policies
explicitly:
  - FAIL: propagate TIMEDOUT in O(1) (no yield transition).
  - RETURN: existing behavior (switch to yield, surface buffered rows).
  - RETURN_STRICT: switch to yield (so the main-thread drain can pop the
    buffered, sorted prefix) and propagate TIMEDOUT immediately so the BG
    abort path is not delayed by per-row yields.

pipelineCanYieldPartialResults is consolidated from a per-shape boolean
enumeration to a peel chain: optional RPPager_Limiter, optional RPSorter,
then RPNet root. Adds the two SORTBY shapes (RPSorter -> RPNet and
RPPager_Limiter -> RPSorter -> RPNet) without changing behavior for the
shapes already supported in RediSearch#9234.

Adds three pytest cases mirroring the trivial-pipeline coverage:
SORTBY one-shard-paused (sync-pointed for exact partial count),
all-shards-paused, and post-store.

* MOD-13617: WIP add APPLY+SORTBY tests for partial results

* Update tests

* Merge

* Shorten Comments

* Fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants