fluent icon indicating copy to clipboard operation
fluent copied to clipboard

Connection request timed out on heavy traffic

Open Huddie opened this issue 4 years ago • 5 comments

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.

Huddie avatar Jan 05 '21 21:01 Huddie

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

0xTim avatar Mar 05 '21 21:03 0xTim

I will update and get back to you thanks so much

Huddie avatar Mar 05 '21 21:03 Huddie

I'm experiencing the same issue using Fluent + MySQL

georgmay avatar Apr 23 '21 09:04 georgmay

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

Huddie avatar Apr 25 '21 14:04 Huddie

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

kylebrowning avatar Feb 04 '23 16:02 kylebrowning