Fix internal cursors not being deleted immedietly in cluster mode - [MOD-12493]#7399
Fix internal cursors not being deleted immedietly in cluster mode - [MOD-12493]#7399
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7399 +/- ##
==========================================
+ Coverage 84.81% 84.86% +0.04%
==========================================
Files 346 347 +1
Lines 53420 53684 +264
Branches 14039 14292 +253
==========================================
+ Hits 45309 45558 +249
- Misses 7915 7930 +15
Partials 196 196
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fbe64f5 to
151a77e
Compare
|
Just for info, should we run a Benchmark scenario? |
Automated performance analysis summaryThis comment was automatically generated given there is performance data available. In summary:
You can check a comparison in detail via the grafana link ## DetailsTests with No Significant Changes (5 tests)Tests with No Significant Changes
|
Automated performance analysis summaryThis comment was automatically generated given there is performance data available. In summary:
You can check a comparison in detail via the grafana link Performance Regressions and Issues - Comparison between master and guyav-fix_command_rewrite.Time Period from 30 days ago. (environment used: oss-standalone)
Tests with No Significant Changes (6 tests)Tests with No Significant Changes
|
Automated performance analysis summaryThis comment was automatically generated given there is performance data available. In summary:
You can check a comparison in detail via the grafana link Performance Improvements - Comparison between master and guyav-fix_command_rewrite.Time Period from 30 days ago. (environment used: oss-standalone)
Performance Regressions and Issues - Comparison between master and guyav-fix_command_rewrite.Time Period from 30 days ago. (environment used: oss-standalone)
Tests with No Significant Changes (31 tests)Tests with No Significant Changes
|
|
Successfully created backport PR for |
…de - [MOD-12493] (#7455) Fix internal cursors not being deleted immedietly in cluster mode - [MOD-12493] (#7399) * refresh cache on every modification * add a failing test * fix bug * add assert to cover a future edge case * remove redundant cleanup * use helper (cherry picked from commit 54f050c) Co-authored-by: GuyAv46 <[email protected]>
Refresh Command's Cached
sdson Every ModificationSince version 8.4, we have started reusing commands to avoid reallocating on every reuse (for example, internal cursor read, which remains constant between calls).
In some cases, a cursor del command is sent to clean leftover cursors at the shards when the user command is finished (or a user cursor was deleted).
Because the command modification was done on the command's argv (
strs) directly, if the command was already used, the argv was not parsed again. The cached command (generated when the command is sent) was triggered instead, so if the cursors were not depleted by this read instead of del, the cursor would remain orfand.This is not too bad, as we eventually will clean these cursors when they are idle for long enough, but they could cause us to reach the cursor limit per index faster, increase memory spikes, and it was not the intended behavior.
In this PR, we add a cache drop on every command modification (through the command API) and use it for the detected scenario. This will also ensure that no similar bugs will happen in the future.
Mark if applicable
Note
Invalidate MRCommand's cached sds on every argv mutation and use safe arg replacement so pending shard cursors get proper DELs; add regression test.
dropCachedCmdIfNeededand call it fromMRCommand_Free,assignStr, andMRCommand_ReplaceArgNoDupto invalidate cachedcmd->cmdafter any mutation insrc/coord/rmr/command.c.MRCommand_ReplaceArgSubstringto prevent in-place edits after cached command creation.MRCommand_SetSlotInfo) now covered centrally.getCursorCommandand iterator release logic, replace manual string edits (strcpy/lens tweaks) withMRCommand_ReplaceArgto switchREAD→DEL/PROFILE, ensuring cache is refreshed (src/coord/hybrid/dist_utils.c,src/coord/rmr/rmr.c).test_mod_12493validating internal shard cursors receive exactly oneREADthen aDEL, and are fully deleted; checksCOMMANDSTATSandcursor_stats(tests/pytests/test_issues.py).Written by Cursor Bugbot for commit da786d2. This will update automatically on new commits. Configure here.