-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running simultaneous queries with relations stalls typeorm #4738
Comments
Got the same issue :-( |
Is there any alternative solution to this problem, other than those suggested by OP? |
@jwhitmarsh |
Same thing here; especially if you have a queue for operations; in our case, it is the RabbitMQ and requests from other microservices that can overwhelm the service when it is down for a while; like when stuck due to this issue; therefore pushing it to stay in this state forever. Please consider taking a look into this issue as it almost makes it impossible to write a real world application with the Postgres driver. |
My problem was that I tried to use I also tried to reproduce the provided sample code here and it works as expected. So I don't know if this specific issue still exists. |
Same happenned to me. Seems like issue with relations loading when |
@Stene3 I have been running into the same issue using |
We just ran into this issue as well, thought it might've run out of memory, but the only thing that makes sense is the connection pool issue. App just stopped responding to requests. |
UP! |
We just ran into this issue as well. |
Same issue with us, we rolled out an API performance update via this at the time "magical" setting, however, we get the same thing, basically is like our API is on a timer before it falls over. Its a function app on Azure, so once this issue arises, the ENTIRE function needs to be restarted to create a new instance of typeORM. Our workaround that doesn't crash the API is a poolSize of 100, this only works because our DB connection errors out first, which thankfully, isn't completely breaking the typeORM manager, and throws the appropriate errors so it will start working again as they clear out. |
Same issue here. Using NestJS with TypeORM, Postgresql. Running more concurrent queries than a number in poolSize specified causes full stall from any further database queries.
|
@darius-00 I've experienced exactly the same issue, then an entire server restart is required. I've found some "hidden" config options that are helping, but still unusual as no errors are thrown when the limit is reached, its like typeORM just silently dies with no way to reboot without entire restart. My hunch is that as we are in a "serverless" api environment, maybe its initialising the datasource more than once so even with max set, its only Here's some extra config that prevented everything falling over at the very least for us (So far): const extra = {
ssl: DB_DEV ? false : true,
max: DB_MAX ? Number(DB_MAX) : DEFAULT_MAX,
poolSize: DB_POOL_SIZE ? Number(DB_POOL_SIZE) : DEFAULT_POOL_SIZE,
connectionTimeoutMillis: DB_CONNECTION_TIMEOUT_MILLIS
? Number(DB_CONNECTION_TIMEOUT_MILLIS)
: DEFAULT_CONNECTION_TIMEOUT_MILLIS,
query_timeout: DB_QUERY_TIMEOUT ? Number(DB_QUERY_TIMEOUT) : DEFAULT_QUERY_TIMEOUT,
statement_timeout: DB_STATEMENT_TIMEOUT
? Number(DB_STATEMENT_TIMEOUT)
: DEFAULT_STATEMENT_TIMEOUT,
};
export const AppDataSource = new DataSource({
type: "postgres",
host: DB_HOST,
port: Number(DB_PORT),
username: DB_USERNAME,
password: DB_PASSWORD,
database: DB_DATABASE,
extra,
logging: DB_LOG ? JSON.parse(DB_LOG) : true,
synchronize: false,
entities: entities,
subscribers: [],
migrations: migrations,
...rest,
}); |
When I set |
If you have |
|
The root cause for our deadlock was caused by caused by the N+1 Problem in GraphQL creating dead-lock with query managers + repository queries e.g. 10 query managers were being created, but then we needed some additional data from the database and used a repository query, causing the dead lock with the maxPool size of 10. Query number 11 may not pass go and it creates a deadlock. The solution was to ensure each top level service function only interacts with the database using the same query manager. |
+1 |
it seems to be related to #10481 |
Yes, the new issue is well described. Hopefully it gets more attention. It's quite important feature. |
UP! |
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]
mongodb
[ ]
mssql
[ ]
mysql
/mariadb
[ ]
oracle
[x]
postgres
[ ]
cockroachdb
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
[ ]
expo
TypeORM version:
[ ]
latest
[x]
@next
[ ]
0.x.x
(or put your version here)I ran into an issue where typeorm would just stop responding occasionally, and when looking at the postgres stats I noticed that typeorm kept 10 (the size of the pool) connections open and in idle and didn't seem to ever close them afterwards.
The connections showed up as
Idle | WaitEvent: Client: ClientRead
.Some more investigations seem to indicate that it the issue presents itself when trying to find entities with relations (with the
getManager().find(Entity, options)
syntax).Increasing the pool size can help mitigate the problem, and using the query builder works as a workaround, but is obviously something we'd want to avoid as much as possible in favour of shorter, and clearer syntax.
I don't believe it's a config issue either
Steps to reproduce or a small repository showing the problem:
The text was updated successfully, but these errors were encountered: