25006: read_only_sql_transaction
PostgreSQLWhat does it mean?
A data-modifying command (INSERT/UPDATE/DELETE/DDL) was attempted inside a read-only transaction. The transaction is configured for reads only. Belongs to Class 25 (invalid_transaction_state).
Why does it happen?
SET TRANSACTION READ ONLY or the default_transaction_read_only=on setting; or, most commonly, a write attempt against a read replica (hot standby / streaming replica). Standby servers are read-only by definition.
How to fix it
Route writes to the primary server; check your connection routing that splits reads and writes. If it was set by mistake: SET TRANSACTION READ WRITE; or server-wide default_transaction_read_only=off. Make sure your application sends read-write traffic to the correct node.