Repository navigation
Add POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT to terminate idle in transaction sessions - #37
Open
richturner wants to merge 1 commit into
Open
richturner wants to merge 1 commit into
richturner wants to merge 1 commit into
Conversation
… transaction sessions Sessions left idle in a transaction prevent autovacuum removing dead rows, which bloats frequently updated tables such as the asset table. Default the timeout to 10min; set to 0 to disable.
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUTenvironment variable (default10min), configured the same way asPOSTGRES_MAX_CONNECTIONS. The entrypoint passes it to the server as-c idle_in_transaction_session_timeout=.... Setting it to0or an empty value disables it, and any PostgreSQL time value (e.g.30s,30min) is accepted.A session left idle in a transaction holds back the xmin horizon, so autovacuum can't remove dead rows. On a production instance this left the frequently updated
openremote.assettable with a 177 MB heap for about 2,900 rows (3.7 MB afterVACUUM FULL). The timeout terminates such sessions before they cause bloat.Setting it at image level, rather than with
ALTER DATABASEor in composecommandargs, means:command.pg_dump openremote.Notes
psqlsessions. 10 minutes is far longer than any legitimate manager or Keycloak transaction should sit idle. A terminated session's transaction is rolled back and the pool replaces the connection.max_connections, the argument is appended after any composecommandargs, so it takes precedence over a-c idle_in_transaction_session_timeoutset there.Testing
10min,30s,0and empty values. Each produced the expectedpostgresarguments.SHOW idle_in_transaction_session_timeout;returns10min, and run the manager and Keycloak against it.Related
profile/deploy.ymlpasses the variable throughMerge order: this PR, then the core
deploy.ymlPR, then the docs PR.