vapor / fluent

Vapor ORM (queries, models, and relations) for NoSQL and SQL databases
https://docs.vapor.codes/4.0/fluent/overview/
MIT License
1.32k stars 172 forks source link

Connection request timed out on heavy traffic #716

Open Huddie opened 3 years ago

Huddie commented 3 years ago

Describe the bug

When running a Postgres instance I sometimes get back:

[ERROR] Connection request timed out. This might indicate a connection deadlock in your application.

I've tried updating the connectionPoolTimeout to 1 min but still get this error. It also usually gets up throwing many of these errors in a row until (maybe?) the connection recovers?

    try app.databases.use(
        .postgres(url: Environment.get("POSTGRES_URL")!,
                  connectionPoolTimeout: .minutes(1)
        ),
        as: .psql
    )

It has to deal with maybe 40/50 incoming requests at the same time. It seems to usually do fine when only 5/10 requests are arriving.

To Reproduce

Setup postgres instance with the above init and send maybe 40/50 to the vapor server which processes a filter to retrieve some object from the db.

Expected behavior

A clear and concise description of what you expected to happen.

Environment

note: no Package.resolved file was found. framework: not found toolbox: 18.3.0

Not sure why framework is not found.

        .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
        .package(url: "https://github.com/vapor/fluent.git", from: "4.0.0"),
        .package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.0.0"),

This is running on kubernetes dockerized using the default dockerfile more or less.

0xTim commented 3 years ago

@Huddie there have been some major improvements to the underlying PostgresNIO driver - are you still seeing this issue?

Huddie commented 3 years ago

I will update and get back to you thanks so much

georgmay commented 3 years ago

I'm experiencing the same issue using Fluent + MySQL

Huddie commented 3 years ago

I haven't gotten a chance to check so could still be happening for me as well.

kylebrowning commented 1 year ago

This is still happening for postgres, but does not happen for mysql