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

Cartesian product + Index cause wrong result #1648

Open
Aurora-yzj opened this issue Jan 18, 2024 · 3 comments · May be fixed by #1924
Open

Cartesian product + Index cause wrong result #1648

Aurora-yzj opened this issue Jan 18, 2024 · 3 comments · May be fixed by #1924
Assignees
Labels
bug bug community community Effort - High Effort - High Frequency - Weekly Frequency - Weekly Priority - Now Priority - Now Reach - Everyone Reach - Everyone Severity - S2 Severity - S2

Comments

@Aurora-yzj
Copy link

Memgraph version
2.13.0

Environment
Operating system: Ubuntu 22.04
Architecture: AMD64
Connect method: any connect method
Driver: any driver
With docker

Describe the bug
Memgraph outputs an empty query result when using an index.

To Reproduce
Steps to reproduce the behavior:

  1. Run the following query to insert the initial value and create the index:
CREATE INDEX ON :L6(k38);
CREATE (n0 :L0:L6{k0 : false, k1 : 890765719, k40 : true, k2 : false, k3 : false, k4 : false, k41 : true, k5 : -1311698154, k6 : "MCotH", k37 : false, k36 : true, k39 : false, id : 0});
CREATE (n0 :L0:L6{k0 : true, k1 : 1304545343, k40 : true, k2 : true, k3 : true, k4 : false, k41 : false, k5 : 1173141482, k6 : "kAIBO99", k37 : true, k36 : true, k39 : false, k38 : 269756692, id : 1});
CREATE (n0 :L0:L6:L11{k0 : false, k70 : "Ml7qmnNQ", k1 : 1098267178, k40 : true, k2 : true, k3 : false, k4 : true, k41 : false, k5 : -786706104, k66 : "QTakNN", k6 : "Wzw0uPB", k65 : 1803875538, k68 : "JeNb8E7V1", k67 : false, k37 : true, k36 : true, k69 : -109922962, k39 : false, k38 : -385421608, id : 2});
CREATE (n0 :L0{k1 : -1006597681, k2 : true, k3 : true, k4 : false, k5 : -1599968686, id : 3, k6 : "xikzo6"});
CREATE (n0 :L0:L6{k1 : 1588792135, k40 : true, k2 : false, k3 : false, k4 : true, k41 : true, k5 : 680249422, k6 : "XF7kSg", k37 : false, k36 : false, k39 : false, k38 : 1463404308, id : 4});
CREATE (n0 :L0:L6{k0 : true, k1 : -1731198578, k40 : true, k2 : true, k3 : false, k4 : true, k41 : false, k5 : -376075495, k6 : "wxjyq", k37 : false, k36 : true, k39 : false, k38 : -1643381344, id : 5});
CREATE (n0 :L0{k0 : true, k1 : -421862127, k2 : false, k3 : true, k4 : false, k5 : -804881356, id : 6, k6 : "5uWHrml5"});
CREATE (n0 :L0{k0 : true, k1 : 1186645042, k2 : true, k3 : false, k4 : false, k5 : 317875177, id : 10, k6 : "RQWjl6f"});
CREATE (n0 :L0{k0 : true, k1 : 1501921859, k2 : false, k3 : false, k4 : true, id : 11, k6 : "Go1qNVk"});
CREATE (n0 {id : 12});
CREATE (n0 :L0:L6{k39 : true, k38 : 584961151, k1 : 483108999, k40 : false, k3 : false, k4 : true, k41 : false, k5 : -1058954276, id : 13, k6 : "MdgjILd6", k37 : false, k36 : true});
CREATE (n0 :L0{k0 : false, k2 : true, k3 : true, k4 : false, k5 : 1026284000, id : 14, k6 : "VV3QWuM"});
MATCH (n0 {id : 11}), (n1 {id : 1}) MERGE(n0)-[r :T2{k82 : true, k84 : "cINRUa", k83 : "dhqqVS", k86 : "wbvvzT", id : 15, k87 : "o2E5gn6Pd"}]->(n1);
MATCH (n0 {id : 1}), (n1 {id : 11}) MERGE(n0)-[r :T2{k82 : false, k84 : "MADM6hN", k83 : "yUnpwg5x", k86 : "WPbrxNw", k85 : "OMqJ8U7Qo", id : 16, k87 : "ESCbuJZC"}]->(n1);
MATCH (n0 {id : 6}), (n1 {id : 13}) MERGE(n0)-[r :T2{k82 : true, k84 : "22vAEWLL", k83 : "sfI4CZ", k86 : "0spkB", k85 : "J43Oj0T", id : 17, k87 : "SqpUzADY6"}]->(n1);
MATCH (n0 {id : 12}), (n1 {id : 2}) MERGE(n0)-[r :T2{k82 : true, k84 : "SXPR8", k83 : "7fEVLMo", k86 : "ec5dz7V", id : 18, k87 : "Nl1Qj"}]->(n1);
MATCH (n0 {id : 4}), (n1 {id : 1}) MERGE(n0)-[r :T2{k82 : true, k84 : "c69H0a", k83 : "mmqOkH7aB", k86 : "qnvkL", k85 : "R6yE23qW", id : 19, k87 : "Ti2tmu"}]->(n1);
MATCH (n0 {id : 4}), (n1 {id : 3}) MERGE(n0)-[r :T2{k82 : true, k84 : "Oc5ADxBQv", k83 : "5MJoJ1", k86 : "goIpN", k85 : "kjHxD", id : 20, k87 : "jJxcsJb"}]->(n1);
MATCH (n0 {id : 5}), (n1 {id : 11}) MERGE(n0)-[r :T2{k82 : false, k84 : "cGmCVNy1I", k83 : "4V8NM6", k86 : "GajNPg", k85 : "bvVqb", id : 21, k87 : "T4O2qE"}]->(n1);
MATCH (n0 {id : 0}), (n1 {id : 4}) MERGE(n0)-[r :T2{k82 : true, k84 : "RBnxH", k83 : "W5bjdNwqI", k86 : "UeNbe", k85 : "ox81Ul3", id : 22, k87 : "mkOiK9O"}]->(n1);
MATCH (n0 {id : 1}), (n1 {id : 5}) MERGE(n0)-[r :T2{k83 : "flRLSv", k86 : "BoyJin", k85 : "1XXjRL", id : 23, k87 : "lRDlTXD"}]->(n1);
MATCH (n0 {id : 10}), (n1 {id : 3}) MERGE(n0)-[r :T2{k82 : false, k84 : "6apbxcZF", k83 : "vZKbZ", k86 : "fwXgFPRw", k85 : "zMMwEQDpL", id : 24, k87 : "MVqgG"}]->(n1);
  1. Run the query:
MATCH (n0 :L6 )<-[r0]-(n1), (n2 :L6)<-[r1]-(n3 :L0) UNWIND [1] AS a0 MATCH (n4)<-[r2]-(n5 :L0 :L6) WHERE (((n2.k1) > (n0.k38)))  RETURN *

This query should return some results but it returns an empty result:
image

If we don't create the index in Step 1 (delete the first line in Step 1), then this query will output the result normally:
image

Expected behavior
The query should return normal results with the index created.

Besides, while minimizing the test case, I also found that the UNWIND clause in this query is crucial in reproducing this issue. Hope this will help you locate the root cause. Thank you!

Verification Environment

  • Plain memgraph Docker image
  • Architecture: x86
@Aurora-yzj Aurora-yzj added the bug bug label Jan 18, 2024
@gitbuda gitbuda added Effort - Unknown Effort - Unknown Importance - I1 Importance - I1 Severity - S2 Severity - S2 labels Jan 19, 2024
@karmenrabar karmenrabar added the community community label Jan 19, 2024
@karmenrabar
Copy link

Hello @Aurora-yzj, and thank you for opening this issue! Someone from the team will get back to you.

@DavIvek DavIvek added Effort - Medium Effort - Medium and removed Effort - Unknown Effort - Unknown labels Jan 22, 2024
@hal-eisen-MG hal-eisen-MG added Priority - Now Priority - Now and removed Priority - Now Priority - Now labels Feb 4, 2024
@hal-eisen-MG hal-eisen-MG added the Priority - Now Priority - Now label Feb 11, 2024
@imilinovic imilinovic self-assigned this Feb 11, 2024
@hal-eisen-MG hal-eisen-MG added Priority - Now Priority - Now and removed Priority - Now Priority - Now labels Feb 18, 2024
@hal-eisen-MG hal-eisen-MG added Priority - Next Priority - Next and removed Priority - Now Priority - Now labels Feb 25, 2024
@katarinasupe katarinasupe added Frequency - Weekly Frequency - Weekly and removed Importance - I1 Importance - I1 labels Feb 26, 2024
@katarinasupe katarinasupe added the Reach - Everyone Reach - Everyone label Feb 26, 2024
@imilinovic
Copy link
Contributor

imilinovic commented Feb 26, 2024

I am pausing the issue due to no progress.

This issue only happens in combination of CartesianProduct + right_operator=ScanAllByLabelPropertyRange (which means it only fails for label-property indexes). I've tried multiple equivalent queries but only this one uses CartesianProduct.
The right operator fails to pull anything for some reason.

Also I find it weird that no combination other than the given one produced CartesianProduct using ScanAllByLabelPropertyRange, maybe it is a problem with planner but I don't know enough about it at the moment.

@imilinovic imilinovic removed their assignment Feb 26, 2024
@imilinovic imilinovic changed the title Incorrect Index Handling Causing Wrong Result Cartesian product + Index cause wrong result Feb 26, 2024
@imilinovic imilinovic added Effort - High Effort - High and removed Effort - Medium Effort - Medium labels Feb 26, 2024
@imilinovic
Copy link
Contributor

@Aurora-yzj If that is a blocker for you, try running memgraph with --cartesian-product-enabled=false, I'm pretty sure the issue won't happen then since this is a problem with cartesian product but your queries memory and speed might be impacted due to not using cartesian.

@hal-eisen-MG hal-eisen-MG added Priority - Now Priority - Now and removed Priority - Next Priority - Next labels Mar 26, 2024
@Josipmrden Josipmrden self-assigned this Apr 15, 2024
@andrejtonev andrejtonev linked a pull request May 20, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bug community community Effort - High Effort - High Frequency - Weekly Frequency - Weekly Priority - Now Priority - Now Reach - Everyone Reach - Everyone Severity - S2 Severity - S2
Projects
Status: Work Progress
Development

Successfully merging a pull request may close this issue.

8 participants