Skip to content
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

make evaluation of inner var expr thread-safe #4913

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

jievince
Copy link
Contributor

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

Fix #4844

Description:

How do you solve it?

Special notes for your reviewer, ex. impact of this fix, design document, etc:

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Performance test
  • N/A

Affects:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:

ex. Fixed the bug .....

Comment on lines 42 to +46
{listElement, ConstantExpression::make(pool_, static_cast<int64_t>(i))});
auto *nodeValue = VariableExpression::make(pool_, node->alias());
// The alias of node is converted to a inner variable.
// e.g. MATCH (v:player) WHERE [t in [v] | (v)-[:like]->(t)] RETURN v
// More cases could be found in PathExprRefLocalVariable.feature
auto *nodeValue = VariableExpression::makeInner(pool_, node->alias());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

node->alias() is converted to a inner var expr here.

@@ -316,6 +324,9 @@ class StorageExpressionContext final : public ExpressionContext {

// name -> Value with multiple versions
std::unordered_map<std::string, std::vector<Value>> valueMap_;

// Expression value map that stores the value of innerVar
std::unordered_map<std::string, Value> exprValueMap_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it MT-safe? And I don't see you create different ExprCtx for each thread.

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

auto scatter = [this](size_t begin, size_t end, Iterator *tmpIter) -> StatusOr<DataSet> {

Every thread has its own QueryExpressionContext.

@codecov-commenter
Copy link

Codecov Report

Base: 76.77% // Head: 76.84% // Increases project coverage by +0.06% 🎉

Coverage data is based on head (e32606e) compared to base (28f8994).
Patch coverage: 84.05% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4913      +/-   ##
==========================================
+ Coverage   76.77%   76.84%   +0.06%     
==========================================
  Files        1102     1102              
  Lines       81064    81091      +27     
==========================================
+ Hits        62240    62316      +76     
+ Misses      18824    18775      -49     
Impacted Files Coverage Δ
src/common/context/ExpressionContext.h 100.00% <ø> (ø)
src/common/utils/DefaultValueContext.h 0.00% <0.00%> (ø)
src/graph/context/QueryExpressionContext.h 100.00% <ø> (ø)
src/graph/planner/plan/PlanNode.h 89.42% <ø> (-0.40%) ⬇️
src/graph/planner/plan/Query.h 96.38% <ø> (-0.04%) ⬇️
src/storage/context/StorageExpressionContext.h 50.94% <ø> (-13.21%) ⬇️
src/storage/exec/IndexExprContext.h 33.33% <0.00%> (-3.88%) ⬇️
src/graph/util/ParserUtil.cpp 93.80% <87.50%> (+0.64%) ⬆️
src/storage/context/StorageExpressionContext.cpp 82.08% <87.50%> (+0.73%) ⬆️
.../common/expression/ListComprehensionExpression.cpp 88.00% <100.00%> (ø)
... and 53 more

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.

Copy link
Contributor

@yixinglu yixinglu left a comment

Choose a reason for hiding this comment

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

LGTM

@yixinglu yixinglu merged commit 77f13a1 into vesoft-inc:master Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inner variable read/write conflict when run executor in parallel.
5 participants