risingwavelabs/risingwave · error · PsqlError
terminating connection due to idle-in-transaction timeout
Error message
terminating connection due to idle-in-transaction timeout
What it means
The server terminates the connection because the session stayed inside a transaction (idle-in-transaction) longer than the configured timeout. This mirrors Postgres's `idle_in_transaction_session_timeout` behavior.
Solutions
- Ensure transactions are committed or rolled back promptly; don't hold them while idle.
- Increase the idle-in-transaction timeout setting if the current limit is too aggressive.
- Fix application code that leaks open transactions (check for missing COMMIT/ROLLBACK on error paths).
- Reconnect after termination; the connection cannot be reused once this error is raised.
Example fix
// before: BEGIN then long idle, no commit conn.begin(); awaitUserInput(); // after: only open the txn when ready awaitUserInput(); conn.begin(); doWork(); conn.commit();
Defensive patterns
Strategy: validation
Validate before calling
-- before running long work, check the setting SHOW idle_in_transaction_session_timeout; -- ensure no txn left open: SELECT state FROM pg_stat_activity WHERE state = 'idle in transaction';
Try / catch
match err {
PsqlError::IdleInTxnTimeout => reconnect_and_replay(),
other => return Err(other),
} Prevention
- Always pair BEGIN with COMMIT/ROLLBACK, including on error paths.
- Use connection-pool health checks that reject idle-in-transaction connections.
- Set application-level statement/transaction timeouts below the server timeout.
- Monitor pg_stat_activity for sessions idle in transaction.
When it happens
Trigger: A client opens a transaction (BEGIN) and then remains idle — issuing no further statements — past the idle-in-transaction timeout configured on the server.
Common situations: Applications that BEGIN a transaction and forget to COMMIT/ROLLBACK; connection poolers holding open transactions; hung application logic mid-transaction; long pauses in interactive psql sessions inside a transaction.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- all request confluent registry all timeout
- apply iceberg fast_append
- apply iceberg pk-index sink overwrite_files action
- {batch write failure, with context()}
- failed to generate AWS MSK IAM token
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/867df1f3bf323a34.
Report an issue: GitHub.
Appendix: source
Thrown at src/utils/pgwire/src/error.rs:84
IoError(#[from] IoError),
/// Uncategorized error for describe, bind.
#[error(transparent)]
Uncategorized(
#[from]
#[backtrace]
BoxedError,
),
#[error("Panicked when handling the request: {0}
This is a bug. We would appreciate a bug report at:
https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Fbug&template=bug_report.yml")]
Panic(String),
#[error("Unable to setup an SSL connection")]
SslError(#[from] openssl::ssl::Error),
#[error("terminating connection due to idle-in-transaction timeout")]
IdleInTxnTimeout,
#[error("Server throttled: {0}")]
ServerThrottle(String),
}
#[derive(Debug)]
pub struct ProtocolViolationError(String);
impl fmt::Display for ProtocolViolationError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl std::error::Error for ProtocolViolationError {
fn provide<'a>(&'a self, request: &mut std::error::Request<'a>) {
request.provide_value(PostgresErrorCode::ProtocolViolation);View on GitHub (pinned to 6469eb736d)