Add error context for sequence synchronization.

An unhandled ERROR while synchronizing a sequence (for example, when
SwitchToUntrustedUser() fails because the subscription owner cannot SET
ROLE to the sequence owner) makes the sequencesync worker exit and be
restarted, repeatedly, until the user resolves the problem, as with the
apply worker. The error message does not identify the sequence or
subscription responsible.

Add an error context callback around per-sequence validation and
synchronization in copy_sequences() so that such errors report the
schema-qualified sequence name and subscription name in CONTEXT.

Reported-by: Zsolt Parragi <[email protected]>
Author: Zhijie Hou <[email protected]>
Reviewed-by: Ajin Cherian <[email protected]>
Reviewed-by: Hayato Kuroda <[email protected]>
Reviewed-by: vignesh C <[email protected]>
Reviewed-by: Zsolt Parragi <[email protected]>
Discussion: 
https://postgr.es/m/can4czfmgiyksxvd1m7cc7_5e+evfi51xmdxw4uqdmvoeh53...@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/215af457aef9b9d0095d2333d126ab817406e9be

Modified Files
--------------
src/backend/replication/logical/sequencesync.c | 32 ++++++++++++++++-
src/test/subscription/t/036_sequences.pl       | 50 ++++++++++++++++++++++++++
2 files changed, 81 insertions(+), 1 deletion(-)

Reply via email to