Error 25003 appears when a branch (sub-transaction or two-phase commit branch) tries to use a read-write or read-only access mode that conflicts with the parent transaction settings.
inappropriate_access_mode_for_branch_transaction (PostgreSQL 25003) means a branch transaction is using an access mode that conflicts with its parent. Open a new top-level transaction or align SET TRANSACTION access mode before creating the branch to resolve the error.
inappropriate_access_mode_for_branch_transaction
PostgreSQL raises error code 25003 when a branch transaction tries to use an access mode that the parent transaction does not allow. A branch is either a savepoint, subtransaction, or a two-phase commit branch managed by an external transaction manager.
The error protects transactional consistency. PostgreSQL refuses to let a read-only branch perform writes or a read-write branch inherit from a parent declared as read-only.
Fixing the mismatch restores normal execution.
Trying to issue SET TRANSACTION READ WRITE inside a savepoint after the parent began as READ ONLY triggers the error immediately.
Running a data-modifying statement inside a branch created under START TRANSACTION READ ONLY also produces the 25003 error.
External two-phase commit frameworks (XA, JTA) that accidentally register a branch in read-write mode while the global transaction is read-only will hit the same error.
Confirm the current access mode by calling SHOW transaction_read_only; then decide whether the branch should follow the parent or run separately.
Set the desired access mode at the start of the top-level transaction, not inside the branch.
If you must mix modes, open a second connection and start a separate transaction.
Savepoints inside reporting queries often break when a later UPDATE sneaks in. Move the UPDATE to its own read-write transaction to avoid the conflict.
Micro-services using pgBouncer transaction pooling can receive conflicting access modes across reused sessions.
Explicitly issue SET default_transaction_read_only = off before BEGIN if writes are needed.
Always declare SET TRANSACTION READ ONLY or READ WRITE immediately after BEGIN and before any SQL runs. This guarantees that branches inherit a consistent mode.
Monitor connection-pool defaults.
Ensure replicas default to read-only and primaries default to read-write so that applications do not mix modes unintentionally.
Error 25002 branch_transaction_already_active arises when you attempt to start a second branch on the same connection. Release the first branch or use another connection.
Error 25006 read_only_sql_transaction occurs when a single statement violates a read-only transaction. Switch to READ WRITE or move the write to a new transaction.
.
No. Access mode must be declared before any SQL executes. Release the savepoint and start a new transaction.
Yes. The setting becomes the default for future transactions, so branches inherit it unless overridden at BEGIN.
Usually not, because replicas refuse writes outright. The error is more common on primaries where mode can switch.
Galaxy surfaces transaction settings in the status bar, warns on mixing modes in a query, and lets teams endorse the correct pattern so others reuse it safely.