Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing regularly using serverless setup with next.js #1242

Open
fredrikburmester opened this issue Dec 12, 2024 · 3 comments
Open

Crashing regularly using serverless setup with next.js #1242

fredrikburmester opened this issue Dec 12, 2024 · 3 comments
Assignees
Labels

Comments

@fredrikburmester
Copy link

Bug Report

Every day or so the connection so my neo4j server crashes. This is probably due to the pool size and connection limits. The app and connection works like a charm for a day and then it just stops.

I have tried increasing memory limits and pool size limits and tweaked timeouts, but nothing works. Almost like clockwork the connection crashes.

I don't know what to do and would really like some help.

Here's a gist of my driver initialization: https://gist.github.com/fredrikburmester/a39aa948843d962e5bd0b783774b7f77

Errors I'm seeing in the logs:

[Error: Connection acquisition timed out in 60000 ms. Pool status: Active conn count = 0, Idle conn count = 0.]

[Error]: Could not perform discovery. No routing servers available. Known routing table: RoutingTable[database=default database, expirationTime=0, currentTime=1733988069189, routers=[], readers=[], writers=[]]
    at d (/app/.next/server/chunks/192.js:5:779)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async o (/app/.next/server/chunks/192.js:1:9163)
    at async o (/app/.next/server/app/(public)/login/page.js:1:13638) {
  errorCode: 'QUERY_FAILED',
  digest: '3375610673'
}

neo4j-driver: 5.27.0
nextjs: 14.2.15 - running in standalone mode in a docker container.
neo4j: 5.19 - running in docker container

@MaxAake MaxAake self-assigned this Dec 12, 2024
@MaxAake
Copy link
Contributor

MaxAake commented Dec 12, 2024

Hello @fredrikburmester !

With what I'm seeing here this looks like a networking issue not related to the driver. There's no apparent misuse of the driver in your provided gist, and the errors you're being shown are the ones I'd expect to see if all your connections were killed and blocked from outside the driver.

I am not an expert in nextjs, but my best guess is that some network policy in it is getting triggered and blocking the drivers traffic, which means it can no longer acquire connections.

If there's details in that make you feel certain that this is a driver error, or if you find out more about this issue, please reach out!

@fredrikburmester
Copy link
Author

Hi, thank you for the response. I also don't hink there's an issue with the actual driver. But maybe there's something that could be done to support serverless applications (reaching here)?

Could you expand on the network policy thing? I'm not sure how to troubleshoot that.

@MaxAake
Copy link
Contributor

MaxAake commented Dec 12, 2024

Hi again, @fredrikburmester ! I caught up on your thread on the community forums, and have been chatting with Gerrit and Adam. I fully agree with them that you should run driver.close() at the end of your executeQuery function, it was my mistake to not notice the creation of a driver without closing it.

In case this doesn't work, or just to check the communication of your application to the server, you could look into the CYPHER function CALL dbms.listConnections() which will let you see if you have a large number of open connections, or if the connections are not making it across at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants