1

The data setup doesn't matter in this case. If I run this query select * from cypher('test', $$ match (a)-[]->(b) with a, count(*) as c return b $$) as (b agtype);

I get this server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. Is this a known bug or is it something from my end? Im using postgreSQL version 12.14 and apacheAGE 1.1.1

  • This query throws an error `ERROR: could not find rte for b` but does not terminate the server. PS: I am on postgres 11. – Zainab Saad Mar 24 '23 at 18:25
  • Can you try after repopulating the graph and see what happens? – Panagiotis Foliadis Mar 24 '23 at 18:41
  • @PanagiotisFoliadis I have tried it on empty and populated table, it says `ERROR: could not find rte for b`. However, I would recommend you to use postgres 11 because the recent commits are made to postgres 11 where multiple issues are resolved. postgres 12 will be updated only before the release. – Zainab Saad Mar 25 '23 at 04:29

2 Answers2

1

This query should error out (as shown below) rather than terminating the server because you are trying to reference b which is not preserved by the WITH clause. Read more about WITH clause here.

ERROR:  could not find rte for b
LINE 1: ...$$ match (a)-[]->(b) with a, count(*) as c return b $$) as (...
                                                             ^

The server crash was due to a bug that is fixed recently. See this issue https://github.com/apache/age/issues/329. So until now, the newest release that is v1.2.0 doesn't incorporate this fix.

If you want to access b after WITH, you would have to pass it on

SELECT * FROM cypher('test', $$
    MATCH (a)-[]->(b) 
    WITH b,a, count(*) AS c 
    RETURN b 
$$) as (b agtype);

                                                        b                                                        
-----------------------------------------------------------------------------------------------------------------
 {"id": 281474976710659, "label": "", "properties": {"a": [7, 8, 9], "name": "node3", "type": "vertex"}}::vertex
 {"id": 281474976710658, "label": "", "properties": {"a": [4, 5, 6], "name": "node2", "type": "vertex"}}::vertex
(2 rows)

If you want to see the changes (i.e error instead of server crash), you would have to pull recent commits from PG12 branch (since you are using postgres 12) and rebuild age.

0

Looking at the query, I believe what you are trying to do is count the number of relationships that "a" has with "b" with the length of one edge between them. So, the number of edges in the graph. If this is the case, the proper way to do this would be something like:

SELECT * FROM cypher('test', $$
    MATCH p = (a)-[]->(b)
    RETURN count(p)
$$) AS (edge_count agtype);

Regarding the error, I used GDB to debug it and it stops at an error when it gets to list_nth_cell on the list.c file. The error that shows is:

0x000000000088906d in ExceptionalCondition (
    conditionName=conditionName@entry=0xa2ac43 "!(n < list->length)", 
    errorType=errorType@entry=0x8d4034 "FailedAssertion", 
    fileName=fileName@entry=0xa560cc "list.c", lineNumber=lineNumber@entry=392)
    at assert.c:54

So maybe when it tries to count it, this n property is greater than the list length, which throws an error. My guess would be that the problem happens in the count(*) part of the query.

Matheus Farias
  • 716
  • 1
  • 10