You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by GitBox <gi...@apache.org> on 2022/05/18 10:58:02 UTC

[GitHub] [incubator-age] jihot2000 opened a new issue, #217: a bug when working with "begin ... commit"

jihot2000 opened a new issue, #217:
URL: https://github.com/apache/incubator-age/issues/217

   **Describe the bug**
   Cannot get  the correct path set when "begin ... commit" is present. 
   
   This bug is found when I wrote a plpgsql function to update a link list stored using AGE. Then I tested this bug by running a sql file with a "begin ... commit" block. And the output is the same as the plpgsql function.
   
   I think it is a bug of the DELETE clause.
   
   **How are you accessing AGE (Command line, driver, etc.)?**
   run a sql file using psql command line
   
   **the sql file**
   ```sql
   \pset pager off
   
   BEGIN;
   
   SET search_path = ag_catalog, "$user", public;
   
   SELECT create_graph('mygraph');
   
   SELECT * FROM cypher('mygraph', $$
       CREATE (a:Node {name: 'a'})-[:Edge]->(c:Node {name: 'c'})
   $$) AS (g1 agtype);
   
   SELECT * FROM cypher('mygraph', $$
       MATCH p = ()-[:Edge*]->()
       RETURN p
   $$) AS (g2 agtype);
   
   SELECT * FROM cypher('mygraph', $$
       MATCH (a:Node {name: 'a'})-[e:Edge]->(c:Node {name: 'c'})
       DELETE e
       CREATE (a)-[:Edge]->(:Node {name: 'b'})-[:Edge]->(c)
   $$) AS (g3 agtype);
   
   SELECT * FROM cypher('mygraph', $$
       MATCH p = ()-[:Edge]->()
       RETURN p
   $$) AS (g4 agtype);
   
   SELECT * FROM cypher('mygraph', $$
       MATCH p = ()-[:Edge*]->()
       RETURN p
   $$) AS (g5 agtype);
   
   SELECT drop_graph('mygraph', true);
   
   COMMIT;
   ```
   
   **Expected behavior**
   The outputs of g5 are different when "begin ... commit" present or not.
   
   When "begin ... commit" is commented, the output is as expected:
   
   ```
                            g5                                                                                                                                                                                                                                                     
   -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    [{"id": 844424930131969, "label": "Node", "properties": {"name": "a"}}::vertex, {"id": 1125899906842627, "label": "Edge", "end_id": 844424930131971, "start_id": 844424930131969, "properties": {}}::edge, {"id": 844424930131971, "label": "Node", "properties": {"name": "b"}}::vertex]::path
    [{"id": 844424930131969, "label": "Node", "properties": {"name": "a"}}::vertex, {"id": 1125899906842627, "label": "Edge", "end_id": 844424930131971, "start_id": 844424930131969, "properties": {}}::edge, {"id": 844424930131971, "label": "Node", "properties": {"name": "b"}}::vertex, {"id": 1125899906842626, "label": "Edge", "end_id": 844424930131970, "start_id": 844424930131971, "properties": {}}::edge, {"id": 844424930131970, "label": "Node", "properties": {"name": "c"}}::vertex]::path
    [{"id": 844424930131971, "label": "Node", "properties": {"name": "b"}}::vertex, {"id": 1125899906842626, "label": "Edge", "end_id": 844424930131970, "start_id": 844424930131971, "properties": {}}::edge, {"id": 844424930131970, "label": "Node", "properties": {"name": "c"}}::vertex]::path
   (3 rows)
   ```
   
   When "begin ... commit" is present, the output has only one row. And this row (a)-[]->(c) should have been deleted.
   
   ```
                                                                                                                                                  g5                                                                                                                                                
   -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    [{"id": 844424930131969, "label": "Node", "properties": {"name": "a"}}::vertex, {"id": 1125899906842625, "label": "Edge", "end_id": 844424930131970, "start_id": 844424930131969, "properties": {}}::edge, {"id": 844424930131970, "label": "Node", "properties": {"name": "c"}}::vertex]::path
   (1 row)
   ```
   
   **Environment (please complete the following information):**
   PostgreSQL 11 and AGE commit id 691fb0d
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-age] jrgemignani commented on issue #217: a bug when working with "begin ... commit"

Posted by GitBox <gi...@apache.org>.
jrgemignani commented on issue #217:
URL: https://github.com/apache/incubator-age/issues/217#issuecomment-1135214031

   The patch has been pushed and this particular issue should be resolved.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-age] JoshInnis commented on issue #217: a bug when working with "begin ... commit"

Posted by GitBox <gi...@apache.org>.
JoshInnis commented on issue #217:
URL: https://github.com/apache/incubator-age/issues/217#issuecomment-1130368665

   It looks like the VLE global contexts are not using the correct graph
   ```
   BEGIN;
   
   SET search_path = ag_catalog, "$user", public;
   
   SELECT create_graph('mygraph');
   
   SELECT * FROM cypher('mygraph', $$
       CREATE (a:Node {name: 'a'})-[:Edge]->(c:Node {name: 'c'})
   $$) AS (g1 agtype);
   
   --Removed VLE call
   
   SELECT * FROM cypher('mygraph', $$
       MATCH (a:Node {name: 'a'})-[e:Edge]->(c:Node {name: 'c'})
       DELETE e
       CREATE (a)-[:Edge]->(:Node {name: 'b'})-[:Edge]->(c)
   $$) AS (g3 agtype);
   
   SELECT * FROM cypher('mygraph', $$
       MATCH p = ()-[:Edge]->()
       RETURN p
   $$) AS (g4 agtype);
   
   SELECT * FROM cypher('mygraph', $$
       MATCH p = ()-[:Edge*]->()
       RETURN p
   $$) AS (g5 agtype);
   
   SELECT drop_graph('mygraph', true);
   
   COMMIT;
   ```
   
   We will take a look into it, for now the workaround I recommend is only use variable length edges once in a transaction


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-age] jihot2000 commented on issue #217: a bug when working with "begin ... commit"

Posted by GitBox <gi...@apache.org>.
jihot2000 commented on issue #217:
URL: https://github.com/apache/incubator-age/issues/217#issuecomment-1130820868

   > It looks like the VLE is not using the correct graph global context
   > 
   > ```
   > BEGIN;
   > 
   > SET search_path = ag_catalog, "$user", public;
   > 
   > SELECT create_graph('mygraph');
   > 
   > SELECT * FROM cypher('mygraph', $$
   >     CREATE (a:Node {name: 'a'})-[:Edge]->(c:Node {name: 'c'})
   > $$) AS (g1 agtype);
   > 
   > --Removed VLE call
   > 
   > SELECT * FROM cypher('mygraph', $$
   >     MATCH (a:Node {name: 'a'})-[e:Edge]->(c:Node {name: 'c'})
   >     DELETE e
   >     CREATE (a)-[:Edge]->(:Node {name: 'b'})-[:Edge]->(c)
   > $$) AS (g3 agtype);
   > 
   > SELECT * FROM cypher('mygraph', $$
   >     MATCH p = ()-[:Edge]->()
   >     RETURN p
   > $$) AS (g4 agtype);
   > 
   > SELECT * FROM cypher('mygraph', $$
   >     MATCH p = ()-[:Edge*]->()
   >     RETURN p
   > $$) AS (g5 agtype);
   > 
   > SELECT drop_graph('mygraph', true);
   > 
   > COMMIT;
   > ```
   > 
   > We will take a look into it, for now the workaround I recommend is only use variable length edges once in a transaction
   
   Thank you for your suggestion.
   
   I tried to append the element 'b' to the end of the link list instead of inserting as follows. The outputs of g5 are still different.
   
   ```sql
   \pset pager off
   
   BEGIN;
   
   SET search_path = ag_catalog, "$user", public;
   
   SELECT create_graph('mygraph');
   
   SELECT * FROM cypher('mygraph', $$
       CREATE (a:Node {name: 'a'})-[:Edge]->(c:Node {name: 'c'})
   $$) AS (g1 agtype);
   
   SELECT * FROM cypher('mygraph', $$
       MATCH p = ()-[:Edge*]->()
       RETURN p
   $$) AS (g2 agtype);
   
   SELECT * FROM cypher('mygraph', $$
       MATCH (c:Node {name: 'c'})
       CREATE (c)-[:Edge]->(:Node {name: 'b'})
   $$) AS (g3 agtype);
   
   SELECT * FROM cypher('mygraph', $$
       MATCH p = ()-[:Edge]->()
       RETURN p
   $$) AS (g4 agtype);
   
   SELECT * FROM cypher('mygraph', $$
       MATCH p = ()-[:Edge*]->()
       RETURN p
   $$) AS (g5 agtype);
   
   SELECT drop_graph('mygraph', true);
   
   COMMIT;
   ```
   
   So, it is not the 'DELETE' clause caused the bug. It is the variable length edges match that caused the bug indeed.
   
   I will use "LOOP ... END LOOP" PL/pgSQL control statements to query my link list  instead of "(head)-[:Edge*]->(node)". It looks ugly, but reliable.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-age] jihot2000 closed issue #217: a bug when working with "begin ... commit"

Posted by GitBox <gi...@apache.org>.
jihot2000 closed issue #217: a bug when working with "begin ... commit"
URL: https://github.com/apache/incubator-age/issues/217


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-age] jrgemignani commented on issue #217: a bug when working with "begin ... commit"

Posted by GitBox <gi...@apache.org>.
jrgemignani commented on issue #217:
URL: https://github.com/apache/incubator-age/issues/217#issuecomment-1131890770

   The VLE, or rather the graph contexts, as the VLE is just one component that can use that mechanism, only updates the graph representation when it is modified. 
   
   After thinking about it, in a begin/commit block, the transaction ids aren't changed, the command ids are; transaction ids are changed from commit to commit. The graph context logic looks at the transaction ids, not the command ids, so it only sees the bigger changes. I need to think about what might result in adding the logic to make it look at both.
   
   To answer your question, it needs to be fixed. But, we need to make sure the fix is correct.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-age] jihot2000 commented on issue #217: a bug when working with "begin ... commit"

Posted by GitBox <gi...@apache.org>.
jihot2000 commented on issue #217:
URL: https://github.com/apache/incubator-age/issues/217#issuecomment-1136112310

   "begin ... commit" bug has been solved


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-age] jrgemignani commented on issue #217: a bug when working with "begin ... commit"

Posted by GitBox <gi...@apache.org>.
jrgemignani commented on issue #217:
URL: https://github.com/apache/incubator-age/issues/217#issuecomment-1130897573

   There is only one context in the VLE for each graph. What is likely happening is that the updates (CREATE and DELETE in this case) aren't causing the  transactions ids to change OR the VLE isn't seeing them change. So, the VLE context isn't getting refreshed. This results in only the updates prior to the first VLE call being seen.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-age] jihot2000 commented on issue #217: a bug when working with "begin ... commit"

Posted by GitBox <gi...@apache.org>.
jihot2000 commented on issue #217:
URL: https://github.com/apache/incubator-age/issues/217#issuecomment-1135311933

   > The patch has been pushed and this particular issue should be resolved.
   
   @jrgemignani Thank you.
   
   This bug has been fixed. But it still has a bug when I run my PL/pgSQL functions with VLE statements.
   
   I opened another issue #220 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-age] jihot2000 commented on issue #217: a bug when working with "begin ... commit"

Posted by GitBox <gi...@apache.org>.
jihot2000 commented on issue #217:
URL: https://github.com/apache/incubator-age/issues/217#issuecomment-1131460655

   > There is only one context in the VLE for each graph. What is likely happening is that the updates (CREATE and DELETE in this case) aren't causing the transactions ids to change OR the VLE isn't seeing them change. Either results in the VLE context not getting refreshed. The end results being that only the updates prior to the first VLE call are being seen.
   
   @jrgemignani Thank you
   
   I wrapped my cypher statements inside PL/gpSQL functions. The users use my wrapped functions to query the database. It is important to ensure the data consistency.
   
   Is the VLE context inconsistency a bug to be fixed? Or it is the correct behaviour of VLE, but I need some other best practice for VLE?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-age] jrgemignani commented on issue #217: a bug when working with "begin ... commit"

Posted by GitBox <gi...@apache.org>.
jrgemignani commented on issue #217:
URL: https://github.com/apache/incubator-age/issues/217#issuecomment-1132000766

   I have created a patch, which is currently in review, to address this issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org