Hi Andrey, Alexander,
I think using GetCatalogSnapshot() here is correct. It is an ordinary
MVCC snapshot, so it pins xmin, while get_toast_snapshot() still returns
SnapshotToast. PushActiveSnapshot() copies it, so later catalog
invalidations do not remove that protection.
This does not make uncommitted catalog changes from a prepared
transaction visible: its XID remains in progress to the catalog
snapshot.
A transaction that accessed temporary objects cannot be prepared, and
the cleanup only writes temporary and system relations, which do not
participate in predicate locking. I additionally tried the reproducer
with a prepared CREATE TABLE.
The existing temp-schema-cleanup isolation test, including its toasted
catalog object, passes with the change. The new test fails without the
fix and passes with it.
The only issue I found is that the new TAP test is missing from the
test_misc list in meson.build.
With that fixed, this looks ready for committer to me.
Thank you!
Best regards, Andrey Borodin.