Keep PostgreSQL transactions below maxParallel
What does this MR do?
It keeps OpenBao's PostgreSQL transactions below maxParallel, so the HA lock renewal always gets a connection.
OpenBao's PostgreSQL storage uses one connection pool for transactions and for the HA lock renewal. With the chart defaults, max_parallel is 5 and transaction_max_parallel is unset, so OpenBao allows up to 64 transactions. A burst of requests can then hold all 5 connections. Every KV read runs in a transaction, so a burst of secret reads is enough. The lock renewal has a 10 s deadline that includes waiting for a connection. When it can't get one, the active node loses its HA lock and steps down.
| Settings | Rendered transaction_max_parallel |
|---|---|
maxParallel: 3 |
2 |
Chart defaults (maxParallel: 5) |
3 |
maxParallel: 20 |
18 |
maxParallel: 20, transactionMaxParallel: 15 |
15 |
maxParallel: null, transactionMaxParallel: null |
Not rendered. OpenBao's defaults already leave room: 64 transactions out of 128 connections. |
- Default
maxParallel - 2: the 2 reserved connections let the lock renewal and a keyring write get one at the same time. The lock checks before commits are short and fit in between. - At least 2 transactions: like OpenBao itself, which never derives a limit below 2 (openbao@5de61eb, in
v2.7.0). Waiting for a transaction never times out, and some code paths start one while holding another, such as a lease tidy revoking a database engine lease. With a single transaction, they would hang forever. - Validation: the render fails when
transactionMaxParallelisn't lower thanmaxParallel(or OpenBao's default of 128). It also fails whenmaxParallelis below 3 andtransactionMaxParallelis unset, because that leaves no room for both the reserve and 2 transactions. The schema rejects atransactionMaxParallelbelow 2. - Version: the chart is bumped to
1.2.0, a minor version, because it adds thetransactionMaxParallelvalue.
This MR doesn't change maxParallel or maxIdleConnections, so OpenBao doesn't open more connections to a PostgreSQL server shared with GitLab. Raising maxIdleConnections is discussed in #47.
Upgrade impact
Installs that keep the defaults go from up to 5 transactions at once to 3. Bursts of reads may queue slightly longer, but they can no longer take every connection and cost the active node its HA lock.
Installs that set maxParallel get maxParallel - 2 transactions, and at least 2. Installs that now fail to render, with an error that says why:
maxParallelbelow 3, withtransactionMaxParallelunset;transactionMaxParallelset tomaxParallelor higher;transactionMaxParallelset below 2.
How to verify
- Run
helm unittest .. The new tests intests/configmap_test.yamlcover the default, the computed value, the floor of 2, an explicit value, both values unset, and the four failure cases. - Run
helm template t . | grep max_parallel. It shows"max_parallel": 5and"transaction_max_parallel": 3.
Locally, all 114 tests pass and helm lint --strict . reports no errors.
Follow-ups
- Document
transactionMaxParallelin the OpenBao chart docs in the GitLab chart, once the GitLab chart uses this chart version. - Add it to the database connection pool table in the Secrets Manager admin docs: https://docs.gitlab.com/administration/secrets_manager/#database-resources
Author's Checklist
Required
- Ensure a release milestone is set.
- MR title and description are up to date, accurate, and descriptive.
- MR targeting the appropriate branch.
- MR has a green pipeline on GitLab.com.
- If the MR changes the packaged chart (
templates/,values.yaml,values.schema.json),versioninChart.yamlis bumped per the release process. - When ready for review, MR is labeled workflowready for review per the MR workflow.
Expected
- Test plan indicating conditions for success has been posted and passes.
- Documentation is created or updated. The docs live in other projects; see the follow-ups.
- Tests are added.
Related issues
- Related to #47