Skip to content

MOD-12984 Persist query warnings across cursor reads #7865

Merged
meiravgri merged 28 commits intomasterfrom
meiravg_persist_warnings_in_areq
Dec 31, 2025
Merged

MOD-12984 Persist query warnings across cursor reads #7865
meiravgri merged 28 commits intomasterfrom
meiravg_persist_warnings_in_areq

Conversation

@meiravgri
Copy link
Collaborator

@meiravgri meiravgri commented Dec 23, 2025

Problem

Profile warnings (timeout, max prefix expansions, OOM, etc.) triggered during early cursor reads were lost by the time the final profile was printed. This happened because warning state was computed fresh at print time from QueryError flags, which is allocated on the stack each read.

Solution

Introduce a ProfileWarnings bitset that accumulates warnings throughout query execution, ensuring all warnings triggered during any cursor read are preserved and reported in the final profile output.

Changes

  1. New ProfileWarnings bitset (profile.h)

    • Added ProfileWarnings type (uint8_t bitset) with warning type enum flags
    • Added ProfileWarnings_Add() and ProfileWarnings_Has() functions
  2. Refactored ProfilePrinterCtx (profile.h)

    • Changed from holding computed boolean flags to {warnings, cursor_reads}
    • Moved cursor_reads from AREQ to ProfilePrinterCtx
    • Removed AREQ.has_timedout (now tracked in bitset)
  3. Updated warning tracking (aggregate_exec.c)

    • Call ProfileWarnings_Add() when each warning condition is detected
    • Warnings accumulate across cursor reads instead of being recomputed
  4. Updated Profile_Print (profile.c)

    • Now accepts AREQ* directly and reads warnings via ProfileWarnings_Has()
    • Updated distributed profile printing to pass AREQ*

Note

Introduces persistent profiling warnings and refactors profile context to ensure warnings raised on any cursor read are preserved and printed.

  • Add ProfileWarnings bitset and helpers; refactor ProfilePrinterCtx to {warnings, cursor_reads} and remove AREQ.has_timedout/move cursor_reads into profile context
  • Update execution paths (aggregate_exec.c) to accumulate warnings (timeout, query OOM, BG scan OOM, max prefix expansions) including empty-reply flows; invoke profile(reply, req) with AREQ*
  • Adjust coordinator paths: pass AREQ* through profile printers (dist_aggregate.c) and iterate RESP3 warnings in dist_utils.c for timeout detection
  • Update Profile_Print to read warnings from bitset and report internal cursor reads from profileCtx
  • Add tests validating BG scan OOM warning in profile, and persistence across timeouts and multiple cursor reads (RESP2/RESP3), plus max-prefix-expansions persistence

Written by Cursor Bugbot for commit 72b9b98. This will update automatically on new commits. Configure here.

@meiravgri meiravgri changed the title make QueryError inline MOD-12984 make QueryError inline Dec 23, 2025
@meiravgri meiravgri force-pushed the meiravg_persist_warnings_in_areq branch from c7684c8 to 7a9740e Compare December 23, 2025 17:20
@meiravgri meiravgri closed this Dec 23, 2025
@meiravgri meiravgri force-pushed the meiravg_persist_warnings_in_areq branch from 0c37fab to 63ec332 Compare December 23, 2025 17:21
Copy link

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

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

❌ Jit has detected 1 important finding in this PR that you should review.


Jit encountered an internal error and cannot comment on each finding.

You can ask a Jit admin to comment #jit_ignore_all on this PR to ignore the findings.

Here are the findings in this PR:

  • Security Control: Static Code Analysis Semgrep Pro
    • Type: Yaml.Github-Actions.Security.Run-Shell-Injection.Run-Shell-Injection
    • Description: Using variable interpolation ${{...}} with github context data in a run: step could allow an attacker to inject their own code into the runner. This would allow them to steal secrets and code. github context data can have arbitrary user input and should be treated as untrusted. Instead, use an intermediate environment variable with env: to store the data and use the environment variable in the run: script. Be sure to use double-quotes the environment variable, like this: "$ENVVAR".
    • Severity: HIGH
    • Learn More: Link
    • Filename: .github/workflows/flow-build-artifacts.yml
    • Lines: 69-90

Copy link

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

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

❌ Jit has detected 2 important findings in this PR that you should review.


Jit encountered an internal error and cannot comment on each finding.

You can ask a Jit admin to comment #jit_ignore_all on this PR to ignore the findings.

Here are the findings in this PR:

  • Security Control: Static Code Analysis Semgrep Pro
    • Type: Yaml.Github-Actions.Security.Run-Shell-Injection.Run-Shell-Injection
    • Description: Using variable interpolation ${{...}} with github context data in a run: step could allow an attacker to inject their own code into the runner. This would allow them to steal secrets and code. github context data can have arbitrary user input and should be treated as untrusted. Instead, use an intermediate environment variable with env: to store the data and use the environment variable in the run: script. Be sure to use double-quotes the environment variable, like this: "$ENVVAR".
    • Severity: HIGH
    • Learn More: Link
    • Filename: .github/workflows/flow-build-artifacts.yml
    • Lines: 70-92
  • Security Control: Static Code Analysis Semgrep Pro
    • Type: Yaml.Github-Actions.Security.Run-Shell-Injection.Run-Shell-Injection
    • Description: Using variable interpolation ${{...}} with github context data in a run: step could allow an attacker to inject their own code into the runner. This would allow them to steal secrets and code. github context data can have arbitrary user input and should be treated as untrusted. Instead, use an intermediate environment variable with env: to store the data and use the environment variable in the run: script. Be sure to use double-quotes the environment variable, like this: "$ENVVAR".
    • Severity: HIGH
    • Learn More: Link
    • Filename: .github/workflows/task-build-artifacts.yml
    • Lines: 260-276

@meiravgri meiravgri reopened this Dec 23, 2025
@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 98.03922% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.04%. Comparing base (a05239e) to head (72b9b98).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/aggregate/aggregate_exec.c 96.55% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7865      +/-   ##
==========================================
- Coverage   84.23%   84.04%   -0.19%     
==========================================
  Files         361      361              
  Lines       56301    55098    -1203     
  Branches    15720    14508    -1212     
==========================================
- Hits        47425    46308    -1117     
+ Misses       8660     8599      -61     
+ Partials      216      191      -25     
Flag Coverage Δ
flow 85.10% <98.03%> (-0.07%) ⬇️
unit 51.07% <0.00%> (-0.93%) ⬇️

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.

introduce ProfileWarnings
return all warnings in sendchunk resp3

return all warnings as an array in profil;e
 add testProfileMultipleWarnings and testPersistProfileWarning_MaxPrefixExpansions

 and test_multiple_warnings
@meiravgri meiravgri changed the title MOD-12984 make QueryError inline MOD-12984 Persist profile warnings across cursor reads Dec 25, 2025
@meiravgri meiravgri changed the title MOD-12984 Persist profile warnings across cursor reads MOD-12984 Persist query warnings across cursor reads Dec 25, 2025
Copy link
Collaborator

@lerman25 lerman25 left a comment

Choose a reason for hiding this comment

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

Let's gamble

@meiravgri meiravgri added this pull request to the merge queue Dec 31, 2025
Merged via the queue into master with commit 2f47432 Dec 31, 2025
32 checks passed
@meiravgri meiravgri deleted the meiravg_persist_warnings_in_areq branch December 31, 2025 11:19
@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 8.2, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 8.2
git worktree add -d .worktree/backport-7865-to-8.2 origin/8.2
cd .worktree/backport-7865-to-8.2
git switch --create backport-7865-to-8.2
git cherry-pick -x 2f474323ba2cec615af4a250b30556016927c0b2

@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 8.4, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 8.4
git worktree add -d .worktree/backport-7865-to-8.4 origin/8.4
cd .worktree/backport-7865-to-8.4
git switch --create backport-7865-to-8.4
git cherry-pick -x 2f474323ba2cec615af4a250b30556016927c0b2

meiravgri added a commit that referenced this pull request Dec 31, 2025
* bit map place holder

* save profilectx in AREQ

introduce ProfileWarnings

* return all warnings in coord reply

return all warnings in sendchunk resp3

return all warnings as an array in profil;e

* align tests to the new format

 add testProfileMultipleWarnings and testPersistProfileWarning_MaxPrefixExpansions

 and test_multiple_warnings

* more fixes

* test fixes

* revert multiple warnings code relted changes

* fixes

* remove tests relarted to #7892

* imp testPersistProfileWarning_MaxPrefixExpansions

* remove temporary test

* fix mising BG indexing OOM

* fix test

* move to header

* add oom test

* asserts

* detect timeout when there are multiple warnings in netCursorCallback

* fix assert

* enhance test_multiple_warnings to test we have exactly 1 cursor read

* fix assert

* test with oom (remove in the next commit)

* fix test - only test with timeout

* comment on ProfileWarningType

* fix test

* remove unused

(cherry picked from commit 2f47432)
meiravgri added a commit that referenced this pull request Jan 1, 2026
* bit map place holder

* save profilectx in AREQ

introduce ProfileWarnings

* return all warnings in coord reply

return all warnings in sendchunk resp3

return all warnings as an array in profil;e

* align tests to the new format

 add testProfileMultipleWarnings and testPersistProfileWarning_MaxPrefixExpansions

 and test_multiple_warnings

* more fixes

* test fixes

* revert multiple warnings code relted changes

* fixes

* remove tests relarted to #7892

* imp testPersistProfileWarning_MaxPrefixExpansions

* remove temporary test

* fix mising BG indexing OOM

* fix test

* move to header

* add oom test

* asserts

* detect timeout when there are multiple warnings in netCursorCallback

* fix assert

* enhance test_multiple_warnings to test we have exactly 1 cursor read

* fix assert

* test with oom (remove in the next commit)

* fix test - only test with timeout

* comment on ProfileWarningType

* fix test

* remove unused

(cherry picked from commit 2f47432)
github-merge-queue bot pushed a commit that referenced this pull request Jan 1, 2026
* MOD-12984 Persist query warnings across cursor reads  (#7865)

* bit map place holder

* save profilectx in AREQ

introduce ProfileWarnings

* return all warnings in coord reply

return all warnings in sendchunk resp3

return all warnings as an array in profil;e

* align tests to the new format

 add testProfileMultipleWarnings and testPersistProfileWarning_MaxPrefixExpansions

 and test_multiple_warnings

* more fixes

* test fixes

* revert multiple warnings code relted changes

* fixes

* remove tests relarted to #7892

* imp testPersistProfileWarning_MaxPrefixExpansions

* remove temporary test

* fix mising BG indexing OOM

* fix test

* move to header

* add oom test

* asserts

* detect timeout when there are multiple warnings in netCursorCallback

* fix assert

* enhance test_multiple_warnings to test we have exactly 1 cursor read

* fix assert

* test with oom (remove in the next commit)

* fix test - only test with timeout

* comment on ProfileWarningType

* fix test

* remove unused

(cherry picked from commit 2f47432)

* fix includes and
github-merge-queue bot pushed a commit that referenced this pull request Jan 1, 2026
* MOD-12984 Persist query warnings across cursor reads  (#7865)

* bit map place holder

* save profilectx in AREQ

introduce ProfileWarnings

* return all warnings in coord reply

return all warnings in sendchunk resp3

return all warnings as an array in profil;e

* align tests to the new format

 add testProfileMultipleWarnings and testPersistProfileWarning_MaxPrefixExpansions

 and test_multiple_warnings

* more fixes

* test fixes

* revert multiple warnings code relted changes

* fixes

* remove tests relarted to #7892

* imp testPersistProfileWarning_MaxPrefixExpansions

* remove temporary test

* fix mising BG indexing OOM

* fix test

* move to header

* add oom test

* asserts

* detect timeout when there are multiple warnings in netCursorCallback

* fix assert

* enhance test_multiple_warnings to test we have exactly 1 cursor read

* fix assert

* test with oom (remove in the next commit)

* fix test - only test with timeout

* comment on ProfileWarningType

* fix test

* remove unused

(cherry picked from commit 2f47432)

* push last
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