You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clearing the whole pool when one physical open times out makes overload worse #6765
Npgsql 10.0.3, EF Core 10, .NET 10, PostgreSQL on AWS RDS (TLS).
What happens
A burst of requests finds no idle connection. The pool opens a physical connection for each, in parallel, limited only by Max Pool Size.
Under that load, opens get slow (TLS, auth, client CPU). One passes Timeout.
NpgsqlConnector.Open calls Break(e, markHostAsOfflineOnConnecting: true). The exception is a transient NpgsqlException wrapping TimeoutException, so Break marks the database offline and calls DataSource.Clear().
Clear() closes all idle connections, and every busy one is closed when it is returned. The waiting requests open new connections, which are slow again, so more opens time out and the pool is cleared again.
In one incident (Max Pool Size=200) we saw about 1,600 physical opens in a few minutes. About 300 failed, and about 1,200 healthy connections were closed by clears. As far as we can tell, the server was up the whole time.
Questions
Is a full clear on one open timeout intended? Here the timeout means the client is overloaded, not that the server is down, and the clear makes it worse.
Is Cancellation Timeout=-1 the intended way to opt out? It also changes how query cancellation works, so it seems too broad.
Would you consider not clearing on an open timeout (only on a real connection failure), or a setting that limits how many physical opens run at once?
Related: #6427 / #6431 stopped the clear for the GSS/TLS retry case. The final failed open still clears.
Our workaround: Min Pool Size = Max Pool Size, all connections opened at startup a few at a time, and Timeout=30.
Activity