[MOD-12416] Create basis for tracking Query Errors and track syntax and args errors#7386
[MOD-12416] Create basis for tracking Query Errors and track syntax and args errors#7386
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7386 +/- ##
==========================================
- Coverage 85.22% 85.12% -0.10%
==========================================
Files 346 346
Lines 52978 53073 +95
Branches 13731 13773 +42
==========================================
+ Hits 45150 45180 +30
- Misses 7634 7699 +65
Partials 194 194
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:
|
| for shardId in range(1, self.env.shardsCount + 1): | ||
| shard_conn = self.env.getConnection(shardId) | ||
| info_dict = info_modules_to_dict(shard_conn) | ||
| args_error_count = info_dict[WARN_ERR_SECTION][ARGS_ERROR_SHARD_METRIC] | ||
| self.env.assertEqual(args_error_count, '0', message=f"Shard {shardId} has wrong initial args error count") |
There was a problem hiding this comment.
consider moving both ARGS_ERROR_SHARD_METRIC and SYNTAX_ERROR_SHARD_METRIC initialization to the init function under the same loop
There was a problem hiding this comment.
This check might be redundant, but if we keep it, I think this is the correct place for this check.
We want to make sure that the other tests in the class didn't add a error to the count, by mistake (Like counting an arg error in the metric because of a syntax error).
There was a problem hiding this comment.
Why not to align the SA tests and check it was increased by 1? also, If you want to test that the args error doesn't increase syntax error (which i agree we should), it should be part of this test, and not the other way around
There was a problem hiding this comment.
Added _verify_metrics_not_changed, that checks all field are not changed
| coord_syntax_error_count = info_dict[COORD_WARN_ERR_SECTION][SYNTAX_ERROR_COORD_METRIC] | ||
| self.env.assertEqual(coord_syntax_error_count, '1') | ||
|
|
||
| def test_args_errors_cluster(self): |
There was a problem hiding this comment.
we should cover here also params error coming from the coordinator, for example invalid limit, for all query types (i think that the fact that FT.SEARCH with invalid limit arg is not a coord error is a bug. you can use a negative number for testing coordintor error)
(cherry picked from commit 4c31dc3)
4c31dc3 to
ac85838
Compare
61269c0 to
a5584f4
Compare
tests/pytests/test_info_modules.py
Outdated
| self.env.assertEqual(coord_args_error_count, '0') | ||
|
|
||
| #### Commented out due to a bug (MOD-12465), when fixed, please enable | ||
| #Note that all the next coord_args_error_count checks should be updated as well |
There was a problem hiding this comment.
| #Note that all the next coord_args_error_count checks should be updated as well | |
| # Note that all the next coord_args_error_count checks should be updated as well |
tests/pytests/test_info_modules.py
Outdated
| if False: | ||
| # Test args errors that are counted in the coord |
There was a problem hiding this comment.
maybe instead of comment out compare to the current result so once it is fixed it will fail
There was a problem hiding this comment.
also, arnt there other param errors we can test?
There was a problem hiding this comment.
also, arnt there other param errors we can test?
Used missing DIALECT param, invokes args error on coord
tests/pytests/test_info_modules.py
Outdated
| self.env.assertEqual(coord_args_error_count, '1') | ||
|
|
||
| # Test args errors in aggregate | ||
| # All args errors in FT.AGGREGATE are counted on the coordinator |
There was a problem hiding this comment.
are you sure?
RediSearch/src/coord/dist_plan.cpp
Line 211 in a5584f4
There was a problem hiding this comment.
I tried reaching this line with ft.aggregate idx hello_world groupby 1 @text reduce count 1 as count
but it reaches an error before that (in the coord)
There was a problem hiding this comment.
The code is really not that clear in regards what is only caught by the shard,
so I changed the comment to
# All args errors in FT.AGGREGATE should be (de facto) counted on the coordinator
If we can find one that can, I will add it
There was a problem hiding this comment.
Bug: Malformed RESP3 Map Protocol Replies
In sendChunk_ReplyOnly_HybridEmptyResults, the warnings section uses RedisModule_Reply_SimpleString(reply, "warnings") instead of RedisModule_ReplyKV_Array(reply, "warnings"). This breaks RESP3 map protocol because warnings is being treated as a simple string value instead of a key-value pair. The subsequent RedisModule_Reply_Array and RedisModule_Reply_SimpleString calls will be malformed within the map structure.
src/hybrid/hybrid_exec.c#L499-L510
RediSearch/src/hybrid/hybrid_exec.c
Lines 499 to 510 in 7f998a9
There was a problem hiding this comment.
Bug: Broken RESP3 Map Structure
The sendChunk_ReplyOnly_HybridEmptyResults function incorrectly uses RedisModule_Reply_SimpleString(reply, "warnings") instead of RedisModule_ReplyKV_Array(reply, "warning") when building the RESP3 map response. This breaks the map structure and doesn't properly create a key-value pair, causing the warnings field to be incorrectly formatted in the response. The implementation should match the corresponding code in sendChunk_hybrid which correctly uses RedisModule_ReplyKV_Array.
src/hybrid/hybrid_exec.c#L461-L463
RediSearch/src/hybrid/hybrid_exec.c
Lines 461 to 463 in 7f998a9
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 2.8
git worktree add -d .worktree/backport-7386-to-2.8 origin/2.8
cd .worktree/backport-7386-to-2.8
git switch --create backport-7386-to-2.8
git cherry-pick -x bf41b7f0ae6d6a9f6625fd9435a6fb23816fef3b |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 2.10
git worktree add -d .worktree/backport-7386-to-2.10 origin/2.10
cd .worktree/backport-7386-to-2.10
git switch --create backport-7386-to-2.10
git cherry-pick -x bf41b7f0ae6d6a9f6625fd9435a6fb23816fef3b |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 8.2
git worktree add -d .worktree/backport-7386-to-8.2 origin/8.2
cd .worktree/backport-7386-to-8.2
git switch --create backport-7386-to-8.2
git cherry-pick -x bf41b7f0ae6d6a9f6625fd9435a6fb23816fef3b |
…nd args errors (#7386) * Query error metric with coord base * remove coord - not used yet * Count syntax and arg errors * Revert "remove coord - not used yet" This reverts commit 8cff9f0. * Seperate into shard error and coord error * tests * Treat SA as shard * Meirav fixups (cherry picked from commit 4c31dc3) * Add future test * fix hybrid SA test * Refractor previous dict check (cherry picked from commit bf41b7f)
|
Successfully created backport PR for |
…ntax and args errors (#7422) * [MOD-12416] Create basis for tracking Query Errors and track syntax and args errors (#7386) * Query error metric with coord base * remove coord - not used yet * Count syntax and arg errors * Revert "remove coord - not used yet" This reverts commit 8cff9f0. * Seperate into shard error and coord error * tests * Treat SA as shard * Meirav fixups (cherry picked from commit 4c31dc3) * Add future test * fix hybrid SA test * Refractor previous dict check (cherry picked from commit bf41b7f) * Replace to c enum --------- Co-authored-by: lerman25 <[email protected]> Co-authored-by: lerman25 <[email protected]>
…and args errors ([#7422](#7422)) * [MOD-12416] Create basis for tracking Query Errors and track syntax and args errors ([#7386](#7386)) * Query error metric with coord base * remove coord - not used yet * Count syntax and arg errors * Revert "remove coord - not used yet" This reverts commit 8cff9f0. * Seperate into shard error and coord error * tests * Treat SA as shard * Meirav fixups (cherry picked from commit 4c31dc3) * Add future test * fix hybrid SA test * Refractor previous dict check (cherry picked from commit bf41b7f) * Replace to c enum --------- Co-authored-by: lerman25 <[email protected]> Co-authored-by: lerman25 <[email protected]> (cherry picked from commit 958b361)
…and args errors ([[#7422](https://github.com/RediSearch/RediSearch/issues/7422)](https://github.com/RediSearch/RediSearch/issues/7422)) * [MOD-12416] Create basis for tracking Query Errors and track syntax and args errors ([[#7386](https://github.com/RediSearch/RediSearch/issues/7386)](https://github.com/RediSearch/RediSearch/issues/7386)) * Query error metric with coord base * remove coord - not used yet * Count syntax and arg errors * Revert "remove coord - not used yet" This reverts commit 8cff9f0. * Seperate into shard error and coord error * tests * Treat SA as shard * Meirav fixups (cherry picked from commit 4c31dc3) * Add future test * fix hybrid SA test * Refractor previous dict check (cherry picked from commit bf41b7f) * Replace to c enum --------- Co-authored-by: lerman25 <[email protected]> Co-authored-by: lerman25 <[email protected]> (cherry picked from commit 958b361)
…ntax … (#7577) [MOD-12416] Create basis for tracking Query Errors and track syntax and args errors ([[#7422](https://github.com/RediSearch/RediSearch/issues/7422)](https://github.com/RediSearch/RediSearch/issues/7422)) * [MOD-12416] Create basis for tracking Query Errors and track syntax and args errors ([[#7386](https://github.com/RediSearch/RediSearch/issues/7386)](https://github.com/RediSearch/RediSearch/issues/7386)) * Query error metric with coord base * remove coord - not used yet * Count syntax and arg errors * Revert "remove coord - not used yet" This reverts commit 8cff9f0. * Seperate into shard error and coord error * tests * Treat SA as shard * Meirav fixups (cherry picked from commit 4c31dc3) * Add future test * fix hybrid SA test * Refractor previous dict check (cherry picked from commit bf41b7f) * Replace to c enum --------- (cherry picked from commit 958b361)
First PR from a series of PRs, aiming to extend the current info metric tracked in RediSearch.
This PR creates the basis for tracking specific query error, starting with
QUERY_ERROR_CODE_ADD_ARGSandQUERY_ERROR_CODE_PARSE_ARGS.It introduces
QueryErrorsGlobalStatsstruct, which keep counters for each error we want to track, andintroduces
QueryErrorsGlobalStats_UpdateErrorfunction, which receivesQueryErrorCode, and update the relevant counter (if the code is tracked).In cluster setting, some args error might be detected in the coord, while others in the shards, so this PR creates individual counter for coord and SA/shards. This separation might also help debug which specific error case was triggered.
Note
Adds global query error counters (syntax/args) split by shard vs coordinator, wires them into SEARCH/AGGREGATE/HYBRID error paths, and surfaces them in INFO MODULES with tests.
QueryErrorsGlobalStatsandQueryErrorsGlobalStats_UpdateError(...)to count query errors by type (syntax,parse_args) and origin (shard vs coordinator).QueriesGlobalStats/TotalGlobalStats_GetQueryStats()to include these counters.aggregate_exec.c,dist_aggregate.c,dist_hybrid.c,hybrid_exec.c, andmodule.cto increment the appropriate shard/coordinator counters before replying.INFO MODULESfields underwarnings_and_errorsandcoordinator_warnings_and_errors:shard_total_query_errors_syntax,shard_total_query_errors_argumentscoord_total_query_errors_syntax,coord_total_query_errors_argumentsFT.SEARCH,FT.AGGREGATE, andFT.HYBRIDacross syntax/args errors and that successful queries don’t change metrics.Written by Cursor Bugbot for commit 7f998a9. This will update automatically on new commits. Configure here.