Skip to content

Bug hitting DB connection max when using withGraphJoined() #1997

@markdoliner

Description

@markdoliner

Hi! I believe I've found a bug where hitting the DB pool max connection limit and getting a legitimate KnexTimeoutError causes future queries to get KnexTimeoutError even when there are available connections in the pool. The latter, illegitimate KnexTimeoutError happens immediately when the query is made rather than after the timeout interval configured in the pool, which I think is telling that this is a bug somewhere.

It seems to happen in a very specific situation:

  • Querying with withGraphJoined().
  • Enough simultaneous queries to hit the DB pool max connection limit and have some queries time out while waiting for an available connection.
  • Hitting the connection limit happens on the first query to the table, or something (I go into a little more detail about this in my comment in the repro case linked to below).

Here's my repro case: https://github.com/markdoliner/objection.js/blob/Repro_case_for_incorrect_timeout_bug/reproduction-template.js

I hoped to be able to track this down further but I don't think I'll be able to spend much time on it in the near future. My hunch is that there's somewhere in Objection where a promise from the first timed out query does not have appropriate error handling and is bleeding over into the subsequent query. But I could be wrong! Don't let me prevent you from exploring other possibilities.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions