You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by "DominicWuest (via GitHub)" <gi...@apache.org> on 2023/05/05 09:10:38 UTC

[GitHub] [age] DominicWuest opened a new issue, #897: Complex `MERGE` causes crash

DominicWuest opened a new issue, #897:
URL: https://github.com/apache/age/issues/897

   I found a bug using my cypher fuzzer.
   
   When running the following query against an empty database:
   ```
   MERGE n0 = (:A)-[:B{n1:0}]->(x:C)-[:D]->(x)-[:E]->(x)<-[:F{n2:0}]-(:G{n3:0})-[:H{n4:0}]->(y:I{n5:0})<-[:J]-(y)<-[:K]-(:L{n6:0})
   ```
   
   The postgres instance crashes and goes into recovery mode.
   
   I encountered this issue when testing queries against the **apache/age:PG13_latest** docker image.
   
   ### Steps to reproduce
   
   Spin up a local instance of **apache/age:PG13_latest**: `docker run -e POSTGRES_PASSWORD=123 --rm --name age apache/age:PG13_latest`
   
   Get a shell in the docker container: `docker exec -it age /bin/bash`
   
   Connect to postgres: `su postgres -c psql`
   
   Run the following queries:
   ```psql
   LOAD 'age';
   -
   SET search_path = ag_catalog, "$user", public;
   -
   SELECT create_graph('graph');
   -
   SELECT * FROM cypher('graph',$$
       MERGE n0 = (:A)-[:B{n1:0}]->(x:C)-[:D]->(x)-[:E]->(x)<-[:F{n2:0}]-(:G{n3:0})-[:H{n4:0}]->(y:I{n5:0})<-[:J]-(y)<-[:K]-(:L{n6:0})
   $$) as (v agtype);
   ```
   
   ### Expected behavior
   The query should run successfully
   
   ### Actual behavior
   The database crashes


-- 
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] [age] mohayu22 commented on issue #897: Complex `MERGE` causes crash

Posted by "mohayu22 (via GitHub)" <gi...@apache.org>.
mohayu22 commented on issue #897:
URL: https://github.com/apache/age/issues/897#issuecomment-1562810024

   ```
   postgres=# SELECT * FROM cypher('test', $$
                MERGE n0 = (:A)-[:B{n1:0}]->(x)-[:D]->(x)-[:E]->(x)<-[:F{n2:0}]-(:G{n3:0})
     $$) AS (res agtype);
   
   server closed the connection unexpectedly
   	This probably means the server terminated abnormally
   	before or while processing the request.
   The connection to the server was lost. Attempting reset: Failed.
   
   ```


-- 
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] [age] jrgemignani commented on issue #897: Complex `MERGE` causes crash

Posted by "jrgemignani (via GitHub)" <gi...@apache.org>.
jrgemignani commented on issue #897:
URL: https://github.com/apache/age/issues/897#issuecomment-1577688559

   PR #961 addresses the source of this crash.


-- 
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] [age] jrgemignani commented on issue #897: Complex `MERGE` causes crash

Posted by "jrgemignani (via GitHub)" <gi...@apache.org>.
jrgemignani commented on issue #897:
URL: https://github.com/apache/age/issues/897#issuecomment-1571155372

   I have created PR #957 to address some of these crashes. It won't address all of them, but it will help to isolate the ones that remain. Basically, there are multiple paths for some of these complex MERGEs to cause a crash, this PR addresses some of those paths.
   


-- 
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] [age] DominicWuest commented on issue #897: Complex `MERGE` causes crash

Posted by "DominicWuest (via GitHub)" <gi...@apache.org>.
DominicWuest commented on issue #897:
URL: https://github.com/apache/age/issues/897#issuecomment-1536360464

   `gdb` stacktrace:
   
   ```
   #0  0x00007f158d9c2d16 in epoll_wait (epfd=4, events=0x5576629cb6b0, 
       maxevents=1, timeout=-1) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30
   #1  0x00005576618ce67c in WaitEventSetWait ()
   #2  0x00005576617cae30 in secure_read ()
   #3  0x00005576617d2947 in ?? ()
   #4  0x00005576617d37e5 in pq_getbyte ()
   #5  0x00005576618f1579 in PostgresMain ()
   #6  0x00005576618794a5 in ?? ()
   #7  0x000055766187a3f4 in PostmasterMain ()
   #8  0x00005576615fc046 in main ()
   ```


-- 
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] [age] jrgemignani commented on issue #897: Complex `MERGE` causes crash

Posted by "jrgemignani (via GitHub)" <gi...@apache.org>.
jrgemignani commented on issue #897:
URL: https://github.com/apache/age/issues/897#issuecomment-1570808750

   Here is a slightly less complicated command that exhibits both errors -
   
   ```
   psql-11.5-5432-pgsql=# SELECT * FROM cypher('test', $$ MERGE ()-[:B]->(x:C)-[:E]->(x:C)<-[f:F]-(y:I) $$) as (r agtype);
   WARNING:  problem in alloc set ExecutorState: detected write past chunk end in block 0x136b500, chunk 0x1378f48
   WARNING:  problem in alloc set ExecutorState: bad single-chunk 0x1378fe0 in block 0x136b500
   server closed the connection unexpectedly
           This probably means the server terminated abnormally
           before or while processing the request.
   The connection to the server was lost. Attempting reset: Failed.
   !>
   ```
   
   It appears that this MERGE bug has to do with memory allocation. It seems likely that the successive tuple creates aren't properly allocating tuples.


-- 
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] [age] jrgemignani commented on issue #897: Complex `MERGE` causes crash

Posted by "jrgemignani (via GitHub)" <gi...@apache.org>.
jrgemignani commented on issue #897:
URL: https://github.com/apache/age/issues/897#issuecomment-1536601182

   @DominicWuest This crash is resolved in the master and is due to variable reuse for labels. Currently, multiple labels are not supported. Additionally, we are still working on allowing variable reuse with labels.
   
   > psql-11.5-5432-pgsql=# SELECT * FROM cypher('graph2',$$
   >     MERGE n0 = (:A)-[:B{n1:0}]->(x:C)-[:D]->(x)-[:E]->(x)<-[:F{n2:0}]-(:G{n3:0})-[:H{n4:0}]->(y:I{n5:0})<-[:J]-(y)<-[:K]-(:L{n6:0})
   > $$) as (v agtype);
   > ERROR:  multiple labels for variable 'x' are not supported
   > LINE 2:     MERGE n0 = (:A)-[:B{n1:0}]->(x:C)-[:D]->(x)-[:E]->(x)<-[...
   >                                                     ^
   > psql-11.5-5432-pgsql=#
   


-- 
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] [age] DominicWuest closed issue #897: Complex `MERGE` causes crash

Posted by "DominicWuest (via GitHub)" <gi...@apache.org>.
DominicWuest closed issue #897: Complex `MERGE` causes crash
URL: https://github.com/apache/age/issues/897


-- 
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] [age] dehowef commented on issue #897: Complex `MERGE` causes crash

Posted by "dehowef (via GitHub)" <gi...@apache.org>.
dehowef commented on issue #897:
URL: https://github.com/apache/age/issues/897#issuecomment-1562016244

   @jrgemignani @DominicWuest I am currently on the latest commit and I cannot get this to crash


-- 
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] [age] mohayu22 commented on issue #897: Complex `MERGE` causes crash

Posted by "mohayu22 (via GitHub)" <gi...@apache.org>.
mohayu22 commented on issue #897:
URL: https://github.com/apache/age/issues/897#issuecomment-1562807465

   ```
   postgres=# SELECT * FROM cypher('test', $$
          MERGE n0 = (x)-[:A]->(x)-[:B]->(x)-[:C]->(x)
    $$) AS (res agtype);
   WARNING:  problem in alloc set ExecutorState: bad single-chunk 0x560be8f472b0 in block 0x560be8f3e5c0
   WARNING:  problem in alloc set ExecutorState: detected write past chunk end in block 0x560be8f3e5c0, chunk 0x560be8f472b0
   WARNING:  problem in alloc set ExecutorState: found inconsistent memory block 0x560be8f3e5c0
   WARNING:  problem in alloc set ExecutorState: bad single-chunk 0x560be8f472b0 in block 0x560be8f3e5c0
   WARNING:  problem in alloc set ExecutorState: detected write past chunk end in block 0x560be8f3e5c0, chunk 0x560be8f472b0
   WARNING:  problem in alloc set ExecutorState: found inconsistent memory block 0x560be8f3e5c0
    res 
   -----
   (0 rows)
   
   ```


-- 
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] [age] jrgemignani commented on issue #897: Complex `MERGE` causes crash

Posted by "jrgemignani (via GitHub)" <gi...@apache.org>.
jrgemignani commented on issue #897:
URL: https://github.com/apache/age/issues/897#issuecomment-1536755028

   @DominicWuest Actually, I take that back. I was able to get it to crash.


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