Skip to content

do not cache query params #2803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jan 18, 2023
Merged

do not cache query params #2803

merged 18 commits into from
Jan 18, 2023

Conversation

swilly22
Copy link
Contributor

@swilly22 swilly22 commented Dec 29, 2022

When an execution context is evicted from the query-cache the cached AST is freed this includes query parameters (if specified) these parameters are shared with the original thread who've placed the execution context in the cache in the first place, when this happens the parameters are dropped while they still might be in use causing unexpected behavior.

To resolve this only the AST is cached, query parameters are simply attached to a shallow copy of the AST.

@swilly22 swilly22 added the bug label Dec 29, 2022
@swilly22 swilly22 requested a review from AviAvni December 29, 2022 11:20
@codecov
Copy link

codecov bot commented Jan 1, 2023

Codecov Report

Base: 91.14% // Head: 91.18% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (6e90216) compared to base (c425ad8).
Patch coverage: 99.17% of modified lines in pull request are covered.

❗ Current head 6e90216 differs from pull request most recent head 2d5552a. Consider uploading reports for the commit 2d5552a to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2803      +/-   ##
==========================================
+ Coverage   91.14%   91.18%   +0.03%     
==========================================
  Files         267      267              
  Lines       25488    25512      +24     
==========================================
+ Hits        23232    23262      +30     
+ Misses       2256     2250       -6     
Impacted Files Coverage Δ
src/arithmetic/list_funcs/list_funcs.c 99.00% <ø> (ø)
src/util/cache/cache.c 88.88% <ø> (ø)
src/ast/ast.c 93.03% <97.50%> (-0.13%) ⬇️
src/arithmetic/arithmetic_expression.c 94.06% <100.00%> (+0.10%) ⬆️
src/commands/execution_ctx.c 96.10% <100.00%> (+0.32%) ⬆️
src/query_ctx.c 87.68% <100.00%> (+0.18%) ⬆️
src/procedures/proc_sp_paths.c 95.70% <0.00%> (+0.57%) ⬆️
src/index/index_construct.c 96.70% <0.00%> (+1.09%) ⬆️
src/procedures/proc_ss_paths.c 92.15% <0.00%> (+1.16%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -182,6 +180,7 @@ ExecutionCtx *ExecutionCtx_FromQuery
// set query parameters in the execution AST
AST_SetParamsParseResult(ret->ast, params_parse_result);
} else {
parse_result_free(params_parse_result);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See if we can have a "cleanup goto" where we would handle all clean-ups.

@swilly22 swilly22 merged commit d476c90 into master Jan 18, 2023
@swilly22 swilly22 deleted the paramless-cache branch January 18, 2023 12:46
raz-mon pushed a commit that referenced this pull request Jan 25, 2023
* do not cache query params

* address PR comments

* fix leak

* fix test

* convert params to SIValues

* wip

* delay freeing of parsed params to after the query is parsed

* free parse params when freeing AST

* revert changes to ast_validations.c

* revert arithmetic_expression_construct changes

* emit an error when param value eval fails

Co-authored-by: Avi Avni <avi.avni@gmail.com>
raz-mon pushed a commit that referenced this pull request Jan 25, 2023
* do not cache query params

* address PR comments

* fix leak

* fix test

* convert params to SIValues

* wip

* delay freeing of parsed params to after the query is parsed

* free parse params when freeing AST

* revert changes to ast_validations.c

* revert arithmetic_expression_construct changes

* emit an error when param value eval fails

Co-authored-by: Avi Avni <avi.avni@gmail.com>
AviAvni added a commit that referenced this pull request Jan 25, 2023
* Fix toInteger() and toIntegerOrNull() don't convert Booleans (#2797)

* AR_TOINTEGER: add case for type T_BOOL

* skip [8] toInteger() failing on invalid arguments

* Update TypeConversion2.feature

Co-authored-by: Avi Avni <avi.avni@gmail.com>

* Fix right(), left() length validation (#2801)

* Fix AR_LEFT, AR_RIGHT length validation

* Test mistmatch type and fix error message

* left(), right(): NULL is a valid type for lenght

* Fix argument validation

Co-authored-by: Avi Avni <avi.avni@gmail.com>

* fix using timeout max as default when default not configured (#2808)

* fix using timeout max as default when default not configured

* fix

* do not cache query params (#2803)

* do not cache query params

* address PR comments

* fix leak

* fix test

* convert params to SIValues

* wip

* delay freeing of parsed params to after the query is parsed

* free parse params when freeing AST

* revert changes to ast_validations.c

* revert arithmetic_expression_construct changes

* emit an error when param value eval fails

Co-authored-by: Avi Avni <avi.avni@gmail.com>

* fix multi-hop traverse with name path (#2743)

* Add varLen property to QGEdge

* Test variable-length edge queries

* Fix spacing

* Fix test, remove direction

* Fix test

* Test zero length edge

* Init varLen in QGEdge_New()

* rename varLen to rangeLen

* Rewrite test11_range_length_edges()

* Use QGEdge_VariableLength() and QGEdge_RangeLength

* Replace QGEdge_RangeLength() by QGEdge_LengthOne()

* rename function

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>
Co-authored-by: Avi Avni <avi.avni@gmail.com>

* indegree(), outdegree() - accept array of strings (#2807)

* _AR_NodeDegree() support T_ARRAY argument

* Add tests

* Fix argument validation

* Free array in case of error detected.

* Duplicate comments and use siarray.array[i]

* Update AR_IN() to use SI_ArrayContainsValue()

* Validate comparedNull pointer

* Support only the following two signatures:

* Test indegree() wrong argument number

* Test wrong signature: string and list

* clean

* revert

Co-authored-by: Avi Avni <avi.avni@gmail.com>

* Add ipv6 capability (#2842)

* fix heap remove item (#2827)

* fix heap remove item

* remove utf8 deps

* add test

* wip

* wip

* all unit tests pass

* heap remove element should use pointer cmp instead of cmp cb

* spaces to tabs

Co-authored-by: swilly22 <roi@redislabs.com>
Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* bump version 2.10.6

* Improve edge deletion performance (#2758)

* improve edge deletion

* update simple timer

* improve edge deletion perf

* fix build

* fix test

* fix test

* clean

* address review

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* update ramp

Co-authored-by: nafraf <nafraf@users.noreply.github.com>
Co-authored-by: Avi Avni <avi.avni@gmail.com>
Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>
Co-authored-by: Guy Korland <gkorland@gmail.com>
Co-authored-by: swilly22 <roi@redislabs.com>
AviAvni added a commit that referenced this pull request Jan 25, 2023
* do not cache query params (#2803)

* do not cache query params

* address PR comments

* fix leak

* fix test

* convert params to SIValues

* wip

* delay freeing of parsed params to after the query is parsed

* free parse params when freeing AST

* revert changes to ast_validations.c

* revert arithmetic_expression_construct changes

* emit an error when param value eval fails

Co-authored-by: Avi Avni <avi.avni@gmail.com>

* fix multi-hop traverse with name path (#2743)

* Add varLen property to QGEdge

* Test variable-length edge queries

* Fix spacing

* Fix test, remove direction

* Fix test

* Test zero length edge

* Init varLen in QGEdge_New()

* rename varLen to rangeLen

* Rewrite test11_range_length_edges()

* Use QGEdge_VariableLength() and QGEdge_RangeLength

* Replace QGEdge_RangeLength() by QGEdge_LengthOne()

* rename function

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>
Co-authored-by: Avi Avni <avi.avni@gmail.com>

* Add ipv6 capability (#2842)

* fix heap remove item (#2827)

* fix heap remove item

* remove utf8 deps

* add test

* wip

* wip

* all unit tests pass

* heap remove element should use pointer cmp instead of cmp cb

* spaces to tabs

Co-authored-by: swilly22 <roi@redislabs.com>
Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* bump version 2.8.22

* update ramp

* Improve edge deletion performance (#2758)

* improve edge deletion

* update simple timer

* improve edge deletion perf

* fix build

* fix test

* fix test

* clean

* address review

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* fix build

* fix build

* fix test

* fix

* fix test

* fix

* fix

* fix

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>
Co-authored-by: Avi Avni <avi.avni@gmail.com>
Co-authored-by: nafraf <nafraf@users.noreply.github.com>
Co-authored-by: Guy Korland <gkorland@gmail.com>
Co-authored-by: swilly22 <roi@redislabs.com>
pnxguide pushed a commit to CMU-SPEED/RedisGraph that referenced this pull request Mar 22, 2023
* do not cache query params

* address PR comments

* fix leak

* fix test

* convert params to SIValues

* wip

* delay freeing of parsed params to after the query is parsed

* free parse params when freeing AST

* revert changes to ast_validations.c

* revert arithmetic_expression_construct changes

* emit an error when param value eval fails

Co-authored-by: Avi Avni <avi.avni@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants