Re: BUG #18545: \dt breaks transaction, calling error when executed in SET SESSION AUTHORIZATION
Noah Misch <noah@leadboat.com>
From: Noah Misch <noah@leadboat.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Justin Pryzby <pryzby@telsasoft.com>, Robert Haas <robertmhaas@gmail.com>, Андрей Рачицкий <therealgofman@mail.ru>, pgsql-hackers@lists.postgresql.org
Date: 2024-10-19T23:28:15Z
Lists: pgsql-bugs, pgsql-hackers
Attachments
- RestorePendingSyncs-at-RestoreRelationMap-v1.patch (text/plain) patch v1
On Thu, Sep 19, 2024 at 05:35:33PM -0400, Tom Lane wrote: > So the fix seems clear to me: RestoreRelationMap needs to happen > before anything that could result in catalog lookups. I'm kind > of inclined to move up the adjacent restores of non-transactional > low-level stuff too, particularly RestoreReindexState which has > direct impact on how catalog lookups are done. Thanks for debugging that. RestorePendingSyncs() also changes what RelationInitPhysicalAddr() puts in the relcache entry, so it needs to stay with RestoreRelationMap(). I'm attaching the fix I have in mind. Since the above (commit 126ec0b), the following has been getting an AssertPendingSyncConsistency() trap: make check-tests TESTS=reindex_catalog PG_TEST_INITDB_EXTRA_OPTS='-cwal_level=minimal -cmax_wal_senders=0' In commit range [6e086fa,126ec0b^], that failed differently, reflecting the outdated relmapper. (6e086fa is mostly innocent here, though.) I looked for ways we'd regret not back-patching commit 126ec0b and this, but I didn't find a concrete problem. After InvalidateSystemCaches(), the back-branch parallel worker relcache contains the nailed relations. Each entry then has: - rd_locator possibly outdated - rd_firstRelfilelocatorSubid==0 (correct for rd_locator) - rd_isvalid==false, from RelationReloadNailed() From code comments, I gather RelationCacheInitializePhase2() is the latest we use an rd_locator without first making the relcache entry rd_isvalid=true. If that's right, so long as no catalogs get rd_isvalid=true between InvalidateSystemCaches() and RestorePendingSyncs(), we're okay without a back-patch. I was going to add check-world coverage of this case, but I stopped in light of the tricky deadlocks that led to commit fe4d022 disabling the reindex_catalog test. check-world does reach it, in inplace.spec, if one runs with both wal_level=minimal and debug_parallel_query=regress. (inplace.spec may eventually fail with the same deadlocks. I've not heard of it deadlocking so far, and being a NO_INSTALLCHECK test helps.)
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix parallel worker tracking of new catalog relfilenumbers.
- 67bab53d6442 18.0 landed
-
Restore relmapper state early enough in parallel workers.
- 126ec0bc76d0 18.0 landed
-
Allow parallel workers to cope with a newly-created session user ID.
- 6e086fa2e771 18.0 landed
- f5f30c22ed69 18.0 landed
- 97380d4803d1 14.13 landed
- 849326e49a5d 16.4 landed
- 68855c03878c 12.20 landed
- 5887dd4894db 17.0 landed
- 48536305370a 15.8 landed
- 216201027d90 13.16 landed
-
Clean up handling of client_encoding GUC in parallel workers.
- 0ae5b763ea0e 18.0 landed
-
Fix rd_firstRelfilenodeSubid for nailed relations, in parallel workers.
- fe4d022c8e17 14.0 cited
-
Fix several mistakes around parallel workers and client_encoding.
- 10c0558ffefc 9.6.0 cited