fix: Flush pool as late as possible during schema cache reloading#4645
fix: Flush pool as late as possible during schema cache reloading#4645mkleczek wants to merge 4 commits intoPostgREST:mainfrom
Conversation
d5a6f71 to
7221241
Compare
|
The change seems reasonable. Is there a way to test the previous behavior and that this is an improvement? I'm thinking we have the postgrest/src/PostgREST/Metrics.hs Lines 22 to 33 in 99984d3 Related, just noted these two functions do the same perhaps we should deduplicate: postgrest/src/PostgREST/AppState.hs Lines 271 to 278 in 99984d3 |
Done:
After latest changes they are no longer duplicate as |
a5f9ece to
f9ea218
Compare
@mkleczek Could you split those commits into another PR? 🙏 (without the fix here) That would make it easier to review. |
f9ea218 to
24e71b5
Compare
@steve-chavez Done. Stacked this PR on top of #4658 |
b428649 to
3c033ab
Compare
e601d59 to
16aedf7
Compare
@steve-chavez Rebased on #4668 |
16aedf7 to
0a348f7
Compare
2e23441 to
3e7308f
Compare
e7045db to
e82492b
Compare
DISCLAIMER: This commit was authored entirely by a human without the assistance of LLMs. Some helpers are provided for introspecting metrics already (used in JWT cache tests). This change provides facilities to additionally validate emited Observation events. A new Spec module is also implemented, adding basic tests of schema cache reloading - their main goal is to excercise the new infrastructure.
DISCLAIMER: This commit was authored entirely by a human without the assistance of LLMs. This change introduces a match_log function, that implements lenient matching of log output lines. Tests of log output are retrofited to use the function.
DISCLAIMER: This commit was authored entirely by a human without the assistance of LLMs. Emit a dedicated PoolFlushed observation when the DB pool is released during schema cache reload.
DISCLAIMER: This commit was authored entirely by a human without the assistance of LLMs. retryingSchemaCacheLoad flushes the pool upon every retry before it starts reloading the schema. This is too early as schema reloading might take some time during which new connections might be acquired. The consequence is that: * upon successful schema cache reload we might have some connections created with the old schema cache * we close connections upon each retry and under load we will keep closing and re-opening connections until schema cache load succeeds This change is to make sure we flush the pool only after successful schema cache querying but before loading (so that connections acquired during loading wait for it and do not interfere with timing the loading process).
e82492b to
ba16275
Compare
DISCLAIMER:
This commit was authored entirely by a human without the assistance of LLMs.retryingSchemaCacheLoadflushes the pool upon every retry before it starts reloading the schema. This is too early as schema reloading might take some time during which new connections might be acquired. The consequence is that:This change is to make sure we flush the pool only after successful schema cache querying but before loading (so that connections acquired during loading wait for it and do not interfere with timing the loading process).