Solution skill
Postgres connection pooling not working
Complete solution
Shows how to fix postgres connection pooling not working. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Set persistence.datastores.*.sql.maxConns and maxIdleConns explicitly. 1. cluster with 2k shards (I assume that's the culprit) 1. use Postgres v97 plugin (actual Postgres is v14, we still have to upgrade the plugin) 1.
Steps
cluster with 2k shards (I assume that's the culprit)
- use Postgres v97 plugin (actual Postgres is v14, we still have to upgrade the plugin)
1.
- [tdeebswihart (contributor)]: The CPU/GC load from constant connection and TLS cert recreation comes from sqlx pool defaults (max 2 idle conns, unbounded pool). Set persistence.datastores.*.sql.maxConns and maxIdleConns explicitly. The reporter confirmed connection handling dropped out of the profiles after configuring it.
When to use
You are seeing this: 2. [tdeebswihart (contributor)]: The CPU/GC load from constant connection and TLS cert recreation comes from sqlx pool defaults (max 2 idle conns, unbounded pool). Use this skill when you run into "Postgres connection pooling not working".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
In gh:temporalio/temporal#4975 (Temporal), the issue reported was: Issue temporalio/temporal#4975 (closed, 13 comments): ## Expected Behavior Connections rarely getting opened
Actual Behavior
50% of all CPU load (4 cores) just from opening new connections
[image]
Steps to Reproduce the Problem
- cluster with 2k shards (I assume that's the culprit)
- use Postgres v97 plugin (actual Postgres is v14, we still have to upgrade the plugin)
1.
Specifications
- Version: v1.20
- Platform: Linux, AWS, EKS The verified resolution from the thread: [tdeebswihart (contributor)]: The CPU/GC load from constant connection and TLS cert recreation comes from sqlx pool defaults (max 2 idle conns, unbounded pool). Set persistence.datastores.*.sql.maxConns and maxIdleConns explicitly. The reporter confirmed connection handling dropped out of the profiles after configuring it. Source: mount the host path https at container path //github.com/temporalio/temporal/issues/4975
By @issueatlas · Version 3 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_X6RQtN8gf0CdeYBr5rhfDg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Postgres connection pooling not working <span>— Vectle</span></a>