1

I ran a query on my graph using the following code:

SELECT * FROM cypher('demo_graph') as (v agtype);

However, I forgot to include the query argument for the Cypher function. As a result, the server closed the connection unexpectedly, and I received the error message

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.

I was expecting an exception to be raised instead of the server being terminated.

Abdul Manan
  • 117
  • 5
  • Yes, I have also encountered the same error, multiple times, and in the end, it automatically reconnects to the server and works normally. I recommend You to open an issue regarding this error at https://github.com/apache/age/issues In this case, as the server crashes this transaction is rolled back, and previous changes are committed. So such queries do not affect your database, and your server starts again, safely. – Kamlesh Kumar Feb 24 '23 at 16:40

7 Answers7

0

You are missing the cypher query:

SELECT * FROM cypher('demo_graph', $$ your cypher query goes here $$) as (v agtype);
0

I think the server is terminating and this is happening because of an empty query. To Resolve this issue try using the below code and run

query = "MATCH (n) RETURN n LIMIT 9"
if query.strip() == "":
    raise ValueError("String query empty ")
res = conn.execute(f"SELECT * FROM cypher('my_graph', '{query}') as (v agtype)")
0

The error message you received is correct. The cypher function in Apache AGE expects a query argument. If you do not provide a query argument, the server will terminate abnormally.

The reason for this is that the cypher function is a remote procedure call (RPC). RPCs are a way of calling a function on a remote server. When you call the cypher function, the server starts a new thread to execute the query. If you do not provide a query argument, the server has no way of knowing what query to execute, so it terminates abnormally.

You can avoid this error by providing a query argument to the cypher function.

  • This is was a bug on AGE. You can refer to this [issue](https://github.com/apache/age/issues/718) on AGE's repo. It's fixed now. – Abdul Manan Jun 30 '23 at 15:06
0

Server is terminating abnormally because a cypher query is missing. Use the below query argument to avoid the error:

SELECT * FROM cypher('demo_graph', 
$$ write your cypher query $$)
as (v agtype);
Aadil Bashir
  • 111
  • 5
0

The reason behind the termination of server is missing cypher query. So you need you update your query

SELECT * FROM cypher('demo_graph', $$MATCH (n) RETURN n$$) AS (v agtype);
Mohayu Din
  • 433
  • 9
adil shahid
  • 125
  • 4
0

The bug was fixed in this commit by adding a check for the number of arguments to be exactly two.

Mohayu Din
  • 433
  • 9
0

Your incomplete query requires cypher query to be completed.

Sample Syntax of query:

SELECT * FROM cypher('demo_graph', $$
        //Desired Operations
    $$) AS (n agtype);

Example:

SELECT * FROM cypher('demo_graph', $$
    MATCH (n:Person)
    WHERE n.age > 30
    RETURN n
$$) AS (n agtype);