]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Rearrange logrep worker's snapshot handling some more.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 10 Jun 2021 16:27:27 +0000 (12:27 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 10 Jun 2021 16:27:27 +0000 (12:27 -0400)
commit26383da7d47a140c33271bfd9215fe50959c80e3
tree4c6ae94c4d3d6a2da9505563d34d2576a9f8ae2e
parent2208d71a0099bf51c70e1636e10a3e7dffe6581f
Rearrange logrep worker's snapshot handling some more.

It turns out that worker.c's code path for TRUNCATE was also
careless about establishing a snapshot while executing user-defined
code, allowing the checks added by commit 84f5c2908 to fail when
a trigger is fired in that context.

We could just wrap Push/PopActiveSnapshot around the truncate call,
but it seems better to establish a policy of holding a snapshot
throughout execution of a replication step.  To help with that and
possible future requirements, replace the previous ensure_transaction
calls with pairs of begin/end_replication_step calls.

Per report from Mark Dilger.  Back-patch to v11, like the previous
changes.

Discussion: https://postgr.es/m/B4A3AF82-79ED-4F4C-A4E5-CD2622098972@enterprisedb.com
src/backend/replication/logical/worker.c