Re: Reset snapshot export state on the transaction abort
Dilip Kumar <dilipbalaut@gmail.com>
From: Dilip Kumar <dilipbalaut@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-10-16T10:09:32Z
Lists: pgsql-hackers
Attachments
- v2-0001-Reset-snapshot-export-state-during-abort.patch (text/x-patch) patch v2-0001
On Sat, Oct 16, 2021 at 9:13 AM Michael Paquier <michael@paquier.xyz> wrote: > > While double-checking this stuff, I have noticed something that's > wrong in the patch when a command that follows a > CREATE_REPLICATION_SLOT query resets SnapBuildClearExportedSnapshot(). > Once the slot is created, the WAL sender is in a TRANS_INPROGRESS > state, meaning that AbortCurrentTransaction() would call > AbortTransaction(), hence calling ResetSnapBuildExportSnapshotState() > and resetting SavedResourceOwnerDuringExport to NULL before we store a > NULL into CurrentResourceOwner :) Right, good catch! > One solution would be as simple as saving > SavedResourceOwnerDuringExport into a temporary variable before > calling AbortCurrentTransaction(), and save it back into > CurrentResourceOwner once we are done in > SnapBuildClearExportedSnapshot() as we need to rely on > AbortTransaction() to do the static state cleanup if an error happens > until the command after the replslot creation command shows up. Yeah, this idea looks fine to me. I have modified the patch. In addition to that I have removed calling ResetSnapBuildExportSnapshotState from the SnapBuildClearExportedSnapshot because that is anyway being called from the AbortTransaction. -- Regards, Dilip Kumar EnterpriseDB: http://www.enterprisedb.com
Commits
-
Reset properly snapshot export state during transaction abort
- f49bf8263459 9.6.24 landed
- d1a6a08dfafc 10.19 landed
- 506aa1f71a98 11.14 landed
- a207b8521346 12.9 landed
- 8f4fe8d7f8dc 13.5 landed
- 5b353aaff69c 14.1 landed
- 409f9ca44713 15.0 landed