Re: logical replication of truncate command with trigger causes Assert
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mark Dilger <mark.dilger@enterprisedb.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-06-08T22:55:46Z
Lists: pgsql-hackers
Mark Dilger <mark.dilger@enterprisedb.com> writes: > On master, when a statement level trigger is fired for a replicated truncate command, the following stack trace is generated: Hmm. > I believe the issue was introduced in commit 84f5c2908da which added EnsurePortalSnapshotExists. That's not going to work in the case of logical replication, because there isn't an ActivePortal nor a snapshot. The right way to say that is "commit 84f5c2908da exposed the pre-existing unsafe behavior of this code". It's not okay to run arbitrary user code without holding a snapshot to protect TOAST dereference operations. I suppose that either apply_dispatch or LogicalRepApplyLoop needs to grow some more snapshot management logic, but I've not looked at that code much, so I don't have an opinion on just where to add it. There's a reasonable case to be made that running user code outside a Portal is a just-plain-bad idea, so we should fix the logical apply worker to make it create a suitable Portal. I speculated about that in the commit message for 84f5c2908da, but I don't feel like taking point on such work. regards, tom lane
Commits
-
Don't use Asserts to check for violations of replication protocol.
- fe6a20ce54cb 14.0 landed
- 9eecea7f373a 11.13 landed
- 8b5055812cad 13.4 landed
- 4745c119e01a 10.18 landed
- 1f280e83314f 12.8 landed
-
Rearrange logrep worker's snapshot handling some more.
- eea081ad013d 11.13 landed
- 6e43f1c2df3d 13.4 landed
- 3a09d75b4f6c 14.0 landed
- 26383da7d47a 12.8 landed
-
Restore the portal-level snapshot after procedure COMMIT/ROLLBACK.
- 84f5c2908dad 14.0 cited
-
Logical replication support for TRUNCATE
- 039eb6e92f20 11.0 cited
-
Logical replication support for initial data copy
- 7c4f52409a8c 10.0 cited