Repository navigation
fix: end PostgreSQL transactions left idle for 5 min (TC-2954) - #586
Merged
Merged
Conversation
samgbafa
pushed a commit
that referenced
this pull request
Nov 13, 2026
…-2954) - A protected legacy meeting write takes its space's sequence guard before BEGIN on PostgreSQL too, so it never holds a pooled connection while queueing for it. - A checkpoint save reads its row's metadata before opening the bulk-timeout transaction for the write. - The pool logs a warning when it closes a connection released inside a transaction. - Regression for a deadline during a SeaORM begin through a slow link. The idle-in-transaction timeout moved to its own PR (#586).
samgbafa
pushed a commit
that referenced
this pull request
Nov 13, 2026
…-2954) - A protected legacy meeting write takes its space's sequence guard before BEGIN on PostgreSQL too, so it never holds a pooled connection while queueing for it. - A checkpoint save reads its row's metadata before opening the bulk-timeout transaction for the write. - The pool logs a warning when it closes a connection released inside a transaction. - Regression for a deadline during a SeaORM begin through a slow link. The idle-in-transaction timeout moved to its own PR (#586).
Every connection in the node's PostgreSQL pool sets idle_in_transaction_session_timeout once at connect (database.idle_in_transaction_timeout_ms, default 15000, 0 off), so a stalled or leaked transaction cannot keep holding its locks and pooled connection; the pool replaces the ended session.
…es within the 240 s upload hold (TC-2954)
…and one replacement connection (TC-2954)
…on idle timeout in local mode
samgbafa
force-pushed
the
feat/tc-2954-idle-tx-timeout
branch
from
November 13, 2026 18:33
1efe968 to
1ec889e
Compare
samgbafa
pushed a commit
that referenced
this pull request
Nov 13, 2026
…-2954) - A protected legacy meeting write takes its space's sequence guard before BEGIN on PostgreSQL too, so it never holds a pooled connection while queueing for it. - A checkpoint save reads its row's metadata before opening the bulk-timeout transaction for the write. - The pool logs a warning when it closes a connection released inside a transaction. - Regression for a deadline during a SeaORM begin through a slow link. The idle-in-transaction timeout moved to its own PR (#586).
samgbafa
marked this pull request as ready for review
November 13, 2026 19:59
samgbafa
pushed a commit
that referenced
this pull request
Nov 13, 2026
…-2954) - A protected legacy meeting write takes its space's sequence guard before BEGIN on PostgreSQL too, so it never holds a pooled connection while queueing for it. - A checkpoint save reads its row's metadata before opening the bulk-timeout transaction for the write. - The pool logs a warning when it closes a connection released inside a transaction. - Regression for a deadline during a SeaORM begin through a slow link. The idle-in-transaction timeout moved to its own PR (#586).
This was referenced Nov 13, 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.
Linear: TC-2954 (sibling of #580; related: TC-2961, #583)
Behaviour
Every connection in the node's PostgreSQL pool sets
idle_in_transaction_session_timeoutonce, when it connects. It is set next to the existing sessionstatement_timeout.database.idle_in_transaction_timeout_ms, envTINYCLOUD_DATABASE__IDLE_IN_TRANSACTION_TIMEOUT_MS.0turns it off.KV_UPLOAD_TIMEOUT(240 s). A shorter timeout would fail those writes and slow whole-checkpoint saves.resolve_runtime_config, also used by--validate-config), a non-zero value of 240 s or less is refused, so it cannot be set below that bound by accident.database.statement_timeout_mode = "local", the mode for transaction-pooling proxies. There a sessionSETlands on whichever server connection served it and reaches the proxy's other clients. The scopedSET LOCALlimits are unchanged.idle_in_transaction_timeout_ms,statement_timeout_msandbulk_statement_timeout_msabove 2147483647 (PostgreSQL'sINT_MAXms) are refused at startup. Before, such a value passed validation and every connection then failed, after a deploy had already stopped the old node.tinycloud-sql-identityopens its own pool without this timeout.0inlocalmode.Tests
tinycloud-node-server/tests/postgres_pool_timeouts.rs::postgres_idle_in_transaction_timeout_ends_an_abandoned_transaction5minon a pooled connection;0leaves it off.is_transient_error). The routes therefore answer it with the TC-1054 contract: 503unavailable_retryable, or 500outcome_unknownonce a write began. Statements inside a transaction are never retried, so nothing reconnects in a loop.config::tests::tc2954_startup_rejects_an_idle_in_transaction_timeout_within_the_upload_hold: the default is 300000; 0, 240001 and 2147483647 are accepted; 1, 240000 and 2147483648 are refused.config::tests::startup_rejects_a_statement_timeout_postgres_cannot_hold: a base or bulkstatement_timeoutof 2147483648 is refused; 2147483647 is accepted.config::tests::the_idle_in_transaction_timeout_is_not_set_in_local_mode: noSETinlocalmode; set insessionandoffmodes.