Skip to content

EntityMetadataNotFoundError on some postgres schema DataSource #9454

@fraxken

Description

@fraxken

Issue Description

Note For context on how we use TypeORM, I'v written an article in August.

Expected Behavior

EntityMetadataNotFoundError should not happen.

Actual Behavior

For some unknown reason we have errors EntityMetadataNotFoundError happening only for some DataSource. All DataSource are initialized with the same options (except for the schema property)

Each time the error happen the request became Idle and consume one connection slot on the database. Combined with our WebSocket retry mechanism it consumed all available slots in few minutes.

Steps to Reproduce

Right now we are failing to reproduce. On our DEV & PREPROD the error almost never appear (only on Production where we have a lot of charges).

In Production we have close to 1,000 schemas (for each schema we open a DataSource and we keep it in memory). Since 0.3.x we use our own internal Map with the schema name as key (since there is no more getConnection() etc..).

My Environment

Dependency Version
Operating System debian
Node.js version 16.15.1
Typescript version ^4.6.3
TypeORM version ^0.3.5 (0.3.9 resolved)

Additional Context

We had already identified the error a few months ago on some of our services that failed on the first request for a DataSource (at least this is what I was thinking at the time.. since other requests on the same datasource were ok).

However we had not much errors, so it was still not very serious and we didn't worry more than that.

image

However yesterday for a new Discussion service using WebSocket the issue became just terrible with dozen of No metadata when all clients were connecting at the same time on the WebSocket.

image

At some point there is so much errors and idle requests that the service go crazy (probably cause all sockets are used.. I'v seen EMFILE error at time)
image

Relevant Database Driver(s)

We only work with postgres

DB Type Reproducible
aurora-mysql no
aurora-postgres no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript no
oracle no
postgres yes
react-native no
sap no
spanner no
sqlite no
sqlite-abstract no
sqljs no
sqlserver no

Are you willing to resolve this issue by submitting a Pull Request?

  • ✅ Yes, I have the time, but I don't know how to start. I would need guidance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions