MOD-13735 MOD-13181 Fix FT.PROFILE shard total profile time#8129
MOD-13735 MOD-13181 Fix FT.PROFILE shard total profile time#8129
Conversation
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8129 +/- ##
==========================================
+ Coverage 83.21% 83.26% +0.05%
==========================================
Files 369 369
Lines 55455 55457 +2
Branches 14432 14432
==========================================
+ Hits 46149 46179 +30
+ Misses 9148 9120 -28
Partials 158 158
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:
|
6f0ca61 to
72365ad
Compare
lerman25
left a comment
There was a problem hiding this comment.
Nice! Should we backport?
Pull request was converted to draft
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 2.8
git worktree add -d .worktree/backport-8129-to-2.8 origin/2.8
cd .worktree/backport-8129-to-2.8
git switch --create backport-8129-to-2.8
git cherry-pick -x fd63e0c3cf864804885bb2b2688e4444d861b6aa |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 2.10
git worktree add -d .worktree/backport-8129-to-2.10 origin/2.10
cd .worktree/backport-8129-to-2.10
git switch --create backport-8129-to-2.10
git cherry-pick -x fd63e0c3cf864804885bb2b2688e4444d861b6aa |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 8.2
git worktree add -d .worktree/backport-8129-to-8.2 origin/8.2
cd .worktree/backport-8129-to-8.2
git switch --create backport-8129-to-8.2
git cherry-pick -x fd63e0c3cf864804885bb2b2688e4444d861b6aa |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 8.4
git worktree add -d .worktree/backport-8129-to-8.4 origin/8.4
cd .worktree/backport-8129-to-8.4
git switch --create backport-8129-to-8.4
git cherry-pick -x fd63e0c3cf864804885bb2b2688e4444d861b6aa |
* Fix FT.PROFILE shard total profile time * Avoid double count on non-cursor Timeout Return failures * Move out of the if (Ok | Timeout) block * Add tests * Enhance tests to cover more cases (cherry picked from commit fd63e0c)
|
Successfully created backport PR for |
* Fix FT.PROFILE shard total profile time * Avoid double count on non-cursor Timeout Return failures * Move out of the if (Ok | Timeout) block * Add tests * Enhance tests to cover more cases (cherry picked from commit fd63e0c)
* Fix FT.PROFILE shard total profile time * Avoid double count on non-cursor Timeout Return failures * Move out of the if (Ok | Timeout) block * Add tests * Enhance tests to cover more cases (cherry picked from commit fd63e0c)
* Fix FT.PROFILE shard total profile time * Avoid double count on non-cursor Timeout Return failures * Move out of the if (Ok | Timeout) block * Add tests * Enhance tests to cover more cases (cherry picked from commit fd63e0c)
* Fix FT.PROFILE shard total profile time * Avoid double count on non-cursor Timeout Return failures * Move out of the if (Ok | Timeout) block * Add tests * Enhance tests to cover more cases (cherry picked from commit fd63e0c)
* Fix FT.PROFILE shard total profile time * Avoid double count on non-cursor Timeout Return failures * Move out of the if (Ok | Timeout) block * Add tests * Enhance tests to cover more cases (cherry picked from commit fd63e0c)
* Fix FT.PROFILE shard total profile time * Avoid double count on non-cursor Timeout Return failures * Move out of the if (Ok | Timeout) block * Add tests * Enhance tests to cover more cases (cherry picked from commit fd63e0c)
* Fix FT.PROFILE shard total profile time * Avoid double count on non-cursor Timeout Return failures * Move out of the if (Ok | Timeout) block * Add tests * Enhance tests to cover more cases (cherry picked from commit fd63e0c)
…8154) * MOD-13181 Fix FT.PROFILE shard total profile time (#8129) * Fix FT.PROFILE shard total profile time * Avoid double count on non-cursor Timeout Return failures * Move out of the if (Ok | Timeout) block * Add tests * Enhance tests to cover more cases (cherry picked from commit fd63e0c) * passing tests * simplify tests * pass also coord tests * simplify extract_profile_coordinator_and_shards * Fix profile parsing to handle FT.SEARCH and FT.AGGREGATE Original get_shards_profile only handled FT.AGGREGATE (assumed res['Shards']). FT.SEARCH has different structure: lowercase 'shards' with nested Coordinator (RESP3), different flat list format (RESP2). New extract_profile_coordinator_and_shards handles all 4 cases (FT.SEARCH/ FT.AGGREGATE × RESP2/RESP3) and extracts Coordinator data needed by testProfileTotalTimeConsistencyCluster* tests. * Fix profile parsing for standalone mode Handle standalone mode in extract_profile_coordinator_and_shards by returning empty coordinator and shards when not in cluster mode. * Fix bug
) * pass also coord tests * MOD-13181 Fix FT.PROFILE shard total profile time (#8129) * Fix FT.PROFILE shard total profile time * Avoid double count on non-cursor Timeout Return failures * Move out of the if (Ok | Timeout) block * Add tests * Enhance tests to cover more cases (cherry picked from commit fd63e0c) * fix * Align test_profile.py helper functions with 2.10 backport * Fix RESP2 parsing to capture all values after key Fixed parse_resp2_shards_list and standalone format parsing to use item[1:] instead of item[1] to capture ALL values after the key. This fixes multi-valued fields like 'Result processors profile' which have format ['key', val1, val2, ...]. Added single-element unwrapping to maintain backward compatibility. * Fix RESP3 parsing to handle case-insensitive keys and filter Coordinator - Check for both 'shards'/'Shards' and 'coordinator'/'Coordinator' keys - Filter out Coordinator from shards list (has 'Total Coordinator time' not 'Total profile time') - Handle standalone mode with 'profile' key * Fix RESP3 Coordinator filter to use negative check Filter out entries with 'Total Coordinator time' key instead of filtering for entries with 'Total profile time', since shards may not always have the 'Total profile time' field.
Problem
In cluster mode,
FT.PROFILEreports incorrect "Total profile time" values for each shard. The total time appears smaller than individual Result Processor times within the same shard, which is mathematically impossible since the total should encompass all processor times. This even worse because some non-negligible time is not included in any of the result processors times (e.g shard results serialization in cursor read).Root Cause
The issue occurs when internal cursors are used (cluster mode with FT.AGGREGATE). The timing calculation has a mismatch between how total time and individual processor times are tracked:
initClockis reset on each cursor read at src/aggregate/aggregate_exec.c:1382:profileTotalTimeis calculated only from the last cursor read in src/profile.c:145:This only captures elapsed time since the last
initClockreset.These times are never reset between cursor reads.
Result: When multiple cursor reads occur, RP times accumulate across all reads while total time only measures the final read.
Fix
Accumulate
profileTotalTimeat the end of each cursor read infinishSendChunk(), matching how RP times are accumulated. This ensures total profile time reflects the sum of all cursor read durations, maintaining mathematical consistency with individual processor times.Note
Fixes shard profiling time under cursored executions by accumulating per-read durations into
req->profileTotalTime.finishSendChunk()inaggregate_exec.cto add elapsed time for intermediate cursor reads toprofileTotalTime(final read remains accounted inProfile_Print); use the measureddurationfor global statstests/pytests/test_profile.pyto verify timing consistency:Total profile time≥ sum of Result ProcessorTimeacross RESP2/RESP3, cluster/standalone, and variousSEARCH/AGGREGATEpipelines; include helpersum_rp_times()andProfileTotalTimeConsistency()Written by Cursor Bugbot for commit 382aa9d. This will update automatically on new commits. Configure here.