Skip to content

[2.8] [MOD-11155] Create basic query pause debug command#7653

Merged
meiravgri merged 3 commits into2.8from
backport-omerl-debug-oom-rp-2.8
Dec 4, 2025
Merged

[2.8] [MOD-11155] Create basic query pause debug command#7653
meiravgri merged 3 commits into2.8from
backport-omerl-debug-oom-rp-2.8

Conversation

@meiravgri
Copy link
Collaborator

@meiravgri meiravgri commented Dec 4, 2025

backport #7624 to 2.8
Note: This version doesn't implement support for query debug on cluster env.


Note

Introduces pause-after-N debug processors (before/after specific RP), plus a QUERY_CONTROLLER to resume and inspect paused queries, with supporting APIs and tests.

  • Debug Query Execution:
    • Add PAUSE_BEFORE_RP_N <RP_TYPE> <N> and PAUSE_AFTER_RP_N <RP_TYPE> <N> parsing in src/aggregate/aggregate_debug.c (workers-only), calling PipelineAddPauseRPcount.
    • Implement pause RP (RP_PAUSE) in src/result_processor.{c,h} with RPPauseAfterCount_*, insertion helpers (before/after target RP_TYPE), and StringToRPType.
    • Refactor timeout RP insertion to use shared helper.
    • Extend ResultProcessorType enum to separate non-debug (RP_MAX) from debug types.
  • Debug Context & Control:
    • Add QueryDebugCtx to DebugCTX (src/debug_commands.{c,h}) with pause state and current debug RP tracking.
    • New FT.DEBUG QUERY_CONTROLLER subcommands:
      • SET_PAUSE_RP_RESUME (resume paused query)
      • GET_IS_RP_PAUSED (returns pause status)
      • PRINT_RP_STREAM (lists RP stream; shows DEBUG_RP).
    • Register QUERY_CONTROLLER in debug command table.
  • Docs & Constraints:
    • Document new pause options and limitations in src/aggregate/aggregate_debug.h.
  • Tests & Utilities:
    • Add Python helpers to build debug queries and control/query pause state.
    • New tests for controller arity/errors, pause behavior (before/after), RP stream output, and worker-thread requirements.

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

return REDISMODULE_ERR;
}
return REDISMODULE_OK;
}
Copy link

Choose a reason for hiding this comment

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

Bug: Missing return statement causes undefined behavior

The parseAndCompileDebug function is missing a return statement at the end. If none of the debug argument types (TIMEOUT_AFTER_N, PAUSE_AFTER_RP_N, PAUSE_BEFORE_RP_N) are initialized after successful parsing, the function falls through without returning a value. Since the function returns int, this leads to undefined behavior.

Fix in Cursor Fix in Web

}

self->remaining--;
return base->upstream->Next(base->upstream, r);
Copy link

Choose a reason for hiding this comment

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

Bug: Unsigned counter underflow after pause causes incorrect behavior

In RPPauseAfterCount_Next, when remaining reaches 0 and the pause occurs, the function then unconditionally decrements remaining on line 1274. Since remaining is a uint32_t, this causes an integer underflow from 0 to 4294967295. The pause will only trigger once and never again until this maximum value is exhausted by subsequent calls. The decrement at line 1274 appears intended to run only when remaining is greater than 0, not after the pause completes.

Fix in Cursor Fix in Web

@meiravgri meiravgri changed the title [2.10] [MOD-11155] Create basic query pause debug command [2.8] [MOD-11155] Create basic query pause debug command Dec 4, 2025
@meiravgri meiravgri requested a review from lerman25 December 4, 2025 12:57
lerman25
lerman25 previously approved these changes Dec 4, 2025
* the Server Side Public License v1 (SSPLv1).
*/


Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

// (rpidnext for SA)
// Take this into account when adding more debug types that are modifying the rp pipeline.
PipelineAddTimeoutAfterCount(&debug_req->r, results_count);
return REDISMODULE_OK;
Copy link

Choose a reason for hiding this comment

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

Bug: Multiple debug parameters silently ignored

When users specify multiple debug parameters in the same command (e.g., TIMEOUT_AFTER_N with a pause parameter, or both PAUSE_BEFORE_RP_N and PAUSE_AFTER_RP_N), only one parameter is processed and the others are silently ignored. The early return after handling TIMEOUT_AFTER_N skips any pause parameters. Similarly, when both pause parameters are specified, the || condition enters the block but only processes whichever parameter the before variable selects, ignoring the other. Users receive no error or warning that their parameters were not applied.

Additional Locations (1)

Fix in Cursor Fix in Web

@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 98.75776% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.55%. Comparing base (f2bfe0d) to head (5e1e744).
⚠️ Report is 1 commits behind head on 2.8.

Files with missing lines Patch % Lines
src/aggregate/aggregate_debug.c 92.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              2.8    #7653      +/-   ##
==========================================
+ Coverage   82.15%   87.55%   +5.40%     
==========================================
  Files         203      203              
  Lines       34954    35102     +148     
==========================================
+ Hits        28715    30734    +2019     
+ Misses       6239     4368    -1871     
Flag Coverage Δ
flow 81.94% <98.75%> (-0.21%) ⬇️
unit 42.33% <0.00%> (?)

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.

@meiravgri meiravgri added this pull request to the merge queue Dec 4, 2025
Merged via the queue into 2.8 with commit c500ddb Dec 4, 2025
13 checks passed
@meiravgri meiravgri deleted the backport-omerl-debug-oom-rp-2.8 branch December 4, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants