I am getting connection reset error when trying execute two queries at the same time in arangodb?

842 views Asked by At

I am using arangojs v6.14.1 and arangodb version 3.6.4.. I also have the nodejs express app which is intended to serve client requests.

I am experiencing an issue while executing concurrent requests. The database connection hangup when I concurrently process client requests:

What the app will do when it receives a request?

Open a database connection -

db = new Database(dbConfig.url); 
db.useDatabase(dbConfig.name); 
db.useBasicAuth(dbConfig.username, dbConfig.password);

There are multiple middleware functions that need to access to perform various functions and accessibility checks. And for each middleware I tried to

  • open a new database connection ->
  • perform the action ->
  • close the connection ->
  • return the result to next middleware.

This works fine with single request at a time. But if I tried to call two APIs at same time, I am getting CONNECTIONRESET error. And also throwing socket hangup error.

I tried to commend out the close connection method and it started working fine for a while. But when I increased the number of connections, it again showing the same error as "CONNECTIONRESET".

I have searched the documentation of arangojs regarding the connection manipulation. But I haven't found any information regarding the same.

Any help would be deeply appreciated.

1

There are 1 answers

0
kerry On

This might be too late for you, but I had a similar issue. After talking with ArangoDB support, it turned out to be an issue with sockets.

Looking at the output from netstat -aplnt I was seeing a lot of CLOSE_WAIT and TIME_WAIT messages, indicating that there were A LOT of connections that were not being closed properly.

The solution was to enable persistent connections (see arangojs config for keep-alive and maxSockets) and then re-using a single connection whenever possible. This was more than just a settings change, requiring some code modifications as well.