Allow logical replication workers to ignore default_transaction_read_only.

Sequence synchronization updates sequence state via setval(), which
explicitly calls PreventCommandIfReadOnly(). If
default_transaction_read_only is enabled on the subscriber, this causes
sequencesync workers to fail with "cannot execute setval() in a read-only
transaction". Apply and tablesync workers are not affected, since they
write via direct heap access rather than through these read-only-checked
functions.

Rather than special-casing sequencesync, override
default_transaction_read_only to "off" for all logical replication workers
in InitializeLogRepWorker(), the same way session_replication_role and
search_path are already forced there. This keeps the initialization
uniform.

For PG-19, we kept the fix narrow by overriding
default_transaction_read_only to "off" only for sequencesync workers.

Reported-by: Noah Misch <[email protected]>
Author: vignesh C <[email protected]>
Reviewed-by: Amit Kapila <[email protected]>
Backpatch-through: 19
Discussion: https://postgr.es/m/[email protected]

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4cd02d552263ed8d4b148aaefd24cd9dd8af57ed

Modified Files
--------------
src/backend/replication/logical/sequencesync.c |  8 ++++
src/test/subscription/t/036_sequences.pl       | 51 ++++++++++++++++++++++++++
2 files changed, 59 insertions(+)

Reply via email to