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

Fix extract filter. #4823

Merged
merged 9 commits into from
Nov 18, 2022
Merged

Conversation

Shylock-Hg
Copy link
Contributor

@Shylock-Hg Shylock-Hg commented Nov 4, 2022

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

Close https://github.com/vesoft-inc/nebula-ent/issues/1551

Description:

It caused by extract filter don't reset ok status when the first logical and expr can be split.

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 .....

@Shylock-Hg Shylock-Hg added the ready-for-testing PR: ready for the CI test label Nov 4, 2022
jievince
jievince previously approved these changes Nov 7, 2022
@czpmango
Copy link
Contributor

czpmango commented Nov 7, 2022

Please add some unit tests that can cover the modified behavior in ExtractFilterVisitorTest.cpp.

@czpmango
Copy link
Contributor

czpmango commented Nov 7, 2022

I didn't reproduce the crash.

(root@nebula) [nba]> MATCH (v:player{name: 'Tim Duncan'})-[:like]->(t) WHERE ( (1 == 1 AND (is_edge(t))) OR (v.player.name == 'Tim Duncan')) RETURN v.player.name
+---------------+
| v.player.name |
+---------------+
| "Tim Duncan"  |
| "Tim Duncan"  |
+---------------+
Got 2 rows (time spent 7134/7445 us)

@Shylock-Hg
Copy link
Contributor Author

I didn't reproduce the crash.

(root@nebula) [nba]> MATCH (v:player{name: 'Tim Duncan'})-[:like]->(t) WHERE ( (1 == 1 AND (is_edge(t))) OR (v.player.name == 'Tim Duncan')) RETURN v.player.name
+---------------+
| v.player.name |
+---------------+
| "Tim Duncan"  |
| "Tim Duncan"  |
+---------------+
Got 2 rows (time spent 7134/7445 us)

ent version

@czpmango
Copy link
Contributor

czpmango commented Nov 7, 2022

I didn't reproduce the crash.

(root@nebula) [nba]> MATCH (v:player{name: 'Tim Duncan'})-[:like]->(t) WHERE ( (1 == 1 AND (is_edge(t))) OR (v.player.name == 'Tim Duncan')) RETURN v.player.name
+---------------+
| v.player.name |
+---------------+
| "Tim Duncan"  |
| "Tim Duncan"  |
+---------------+
Got 2 rows (time spent 7134/7445 us)

ent version

Can this issue be reproduced in the community edition? Bcz you are fixing a visitor rather than a rule that only the enterprise version has. For example, PushFilterDownGetNbrsRule also invoked this visitor.

@Shylock-Hg
Copy link
Contributor Author

I didn't reproduce the crash.

(root@nebula) [nba]> MATCH (v:player{name: 'Tim Duncan'})-[:like]->(t) WHERE ( (1 == 1 AND (is_edge(t))) OR (v.player.name == 'Tim Duncan')) RETURN v.player.name
+---------------+
| v.player.name |
+---------------+
| "Tim Duncan"  |
| "Tim Duncan"  |
+---------------+
Got 2 rows (time spent 7134/7445 us)

ent version

Can this issue be reproduced in the community edition? Bcz you are fixing a visitor rather than a rule that only the enterprise version has. For example, PushFilterDownGetNbrsRule also invoked this visitor.

Not sure, I guess it will.

@@ -276,6 +276,7 @@ bool ExtractFilterExprVisitor::visitLogicalOr(LogicalExpression *expr) {
if (canNotPushedIndex != -1 || !canBeSplit) {
return false;
}
Copy link
Contributor

@czpmango czpmango Nov 7, 2022

Choose a reason for hiding this comment

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

Crashed at DCHECK(ok()) in ExprVisitorImpl.cpp:130.
Better to fix else branch:

 else {
      if (!canBePushed_) {
        return false;
      }
      operands[i]->accept(this);
    }

Alternatively, we could do some minor refactoring of this visitor, such as adding additional state variables other than "can" and "cannot" pairs to allow the internal logic to continue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will lead to test fail.

@Shylock-Hg Shylock-Hg added the type/bug Type: something is unexpected label Nov 9, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 9, 2022

Codecov Report

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

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4823      +/-   ##
==========================================
+ Coverage   76.78%   76.84%   +0.06%     
==========================================
  Files        1102     1102              
  Lines       80953    80974      +21     
==========================================
+ Hits        62160    62225      +65     
+ Misses      18793    18749      -44     
Impacted Files Coverage Δ
src/meta/processors/job/JobManager.h 100.00% <ø> (ø)
src/meta/processors/job/JobManager.cpp 70.01% <6.25%> (-1.97%) ⬇️
src/meta/processors/parts/DropSpaceProcessor.cpp 64.35% <58.33%> (-0.82%) ⬇️
src/graph/visitor/ExtractFilterExprVisitor.cpp 75.18% <100.00%> (+0.09%) ⬆️
src/graph/visitor/PropertyTrackerVisitor.cpp 82.97% <100.00%> (-1.28%) ⬇️
src/meta/processors/job/ReportTaskProcessor.cpp 85.71% <100.00%> (ø)
...eta/processors/session/SessionManagerProcessor.cpp 73.54% <0.00%> (-4.52%) ⬇️
src/graph/executor/StorageAccessExecutor.h 58.13% <0.00%> (-2.33%) ⬇️
src/common/base/Status.h 90.56% <0.00%> (-1.89%) ⬇️
... and 32 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.

@@ -276,6 +276,7 @@ bool ExtractFilterExprVisitor::visitLogicalOr(LogicalExpression *expr) {
if (canNotPushedIndex != -1 || !canBeSplit) {
return false;
}
canBePushed_ = true; // reset when the LogicalAnd can be split
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO, this is not a good fix. Just fixed code path, but it's not a natural code logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's only what I can do.

"""
MATCH (v:player{name: 'Tim Duncan'})-[:like]->(t) WHERE ( (1 == 1 AND (NOT is_edge(t))) OR (v.player.name == 'Tim Duncan')) RETURN v.player.name
"""
Then the result should be, in any order:
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to find the crash cases in community edition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't do that.

@Shylock-Hg Shylock-Hg requested a review from czpmango November 18, 2022 02:45
Copy link
Contributor

@czpmango czpmango left a comment

Choose a reason for hiding this comment

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

LGTM for now, but need to consider refactoring later.

@Sophie-Xie Sophie-Xie merged commit 3e2d7b2 into vesoft-inc:master Nov 18, 2022
@Shylock-Hg Shylock-Hg deleted the fix/extract-filter branch November 18, 2022 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test type/bug Type: something is unexpected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants