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 ------ master Details ------- https://git.postgresql.org/pg/commitdiff/d774576f6f05f65e3a944eb509ef0620ea6b107e Modified Files -------------- src/backend/replication/logical/worker.c | 8 +++++ src/test/subscription/t/036_sequences.pl | 51 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+)
