Skip to content

Hikari connection timeouts are delayed when connectEC is exhausted #2453

Description

@Alex1005a

When using the standard function to create a HikariTransactor from a config, fromHikariConfigWithResEffect creates an ExecutionContext whose pool size is equal to Hikari’s maximumPoolSize. As a result, getConnection calls are also limited by that pool.

If the ExecutionContext pool becomes exhausted, additional connection attempts wait before they even reach Hikari. Because of this, Hikari’s connectionTimeout is not observed at the expected time.

For example, with maximumPoolSize = 1, if multiple queries are running at the same time and network requests are no longer reaching the database, the queries fail one after another with a timeout error. With connectionTimeout = 1000 ms, the last query may fail only after about 10 seconds. Also, in this case, cats-effect timeouts do not work as expected.

I think it would be worth providing a function that creates a pool with a bounded queue, as described in this comment on another issue.

Another option would be to provide a function that limits the number of concurrent connection attempts using a Semaphore, with a timeout on acquire.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions