Re: race condition in pg_class
Noah Misch <noah@leadboat.com>
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Replace tests of ALTER DATABASE RESET TABLESPACE.
- 4adb0380b9bf 19 (unreleased) landed
-
meson: Flush stdout in testwrap
- d9bc60705274 16.9 landed
- 9de86e367a67 17.5 landed
- 5941946d0934 18.0 landed
-
Fix catcache invalidation of a list entry that's being built
- af8cd1639ab2 18.0 cited
-
Stop reading uninitialized memory in heap_inplace_lock().
- a0c0078b1355 12.21 landed
- ad24b7565910 14.14 landed
- 3e5ea478d875 13.17 landed
- d34ffbaa1029 15.9 landed
- 2d63c964f010 16.5 landed
- e11907682846 17.1 landed
- e947224cbbce 18.0 landed
-
Fix use of uninitialized value in previous commit.
- 0cf3d41cbb42 15.9 landed
- 90f5412a9a51 16.5 landed
-
Back-patch "Refactor code in tablecmds.c to check and process tablespace moves"
- dc845383cd12 12.21 landed
- 1299564cb9c7 13.17 landed
-
Fix data loss at inplace update after heap_update().
- 7354b680ab64 12.21 landed
- a8ad1929d2ec 13.17 landed
- 8590c942c1a6 15.9 landed
- 82c2d9e02206 14.14 landed
- 63f01980560a 16.5 landed
- fd27b878c2ea 17.1 landed
- a07e03fd8fa7 18.0 landed
-
For inplace update durability, make heap_update() callers wait.
- cafcc3ad0ed3 12.21 landed
- 14c57cb63907 13.17 landed
- f51b34b3eddb 14.14 landed
- 5c837f8fa022 15.9 landed
- 51ff46de29f6 16.5 landed
- 3b7a689e1a80 17.1 landed
- aac2c9b4fde8 18.0 landed
-
Warn if LOCKTAG_TUPLE is held at commit, under debug_assertions.
- b779d37a3db2 12.21 landed
- 5ef9b4a2f796 13.17 landed
- c9de1b8ac8df 14.14 landed
- 41e0ba33d5ab 15.9 landed
- acc63ef4fbe6 16.5 landed
- f33bf1c7d501 17.1 landed
- dbf3f974ee04 18.0 landed
-
Don't lose partitioned table reltuples=0 after relhassubclass=f.
- e81deeefcac2 16.4 landed
- 2b4a2a79edd2 15.8 landed
- 2b415e95a8a7 14.13 landed
- f5bb46fb2e65 17.0 landed
- 7102070329d8 18.0 landed
-
Fix new assertion for MERGE view_name ... DO NOTHING.
- 0d3b35c367c2 17.0 landed
- d5e6891502ca 18.0 landed
-
Remove configuration-dependent output from new inplace-inval test.
- 79567599cd21 12.20 landed
- f31c1e34bc80 14.13 landed
- ca30e8ba958a 13.16 landed
- 7857c8dc4481 16.4 landed
- 458fada72b32 15.8 landed
- b99414de9052 17.0 landed
-
AccessExclusiveLock new relations just after assigning the OID.
- 7af775bbae57 12.20 landed
- e038b7756df8 14.13 landed
- b899cde0b86a 13.16 landed
- 0f2835ea6fc1 15.8 landed
- fc8c25806e84 16.4 landed
- 5b823b179e5e 17.0 landed
-
Cope with inplace update making catcache stale during TOAST fetch.
- 7a21306aee0a 13.16 landed
- 11f3815d6af8 12.20 landed
- af73e37fa181 14.13 landed
- b08a4b6163eb 15.8 landed
- e4afd7153bd8 16.4 landed
- f9f47f0d93d1 17.0 landed
-
Expand comments and add an assertion in nodeModifyTable.c.
- fea47de3016a 12.20 landed
- c3437fb7255b 13.16 landed
- ad4653268c12 14.13 landed
- f0544432c3cc 15.8 landed
- f8135d8b54ff 16.4 landed
- d5f788b41dc2 17.0 landed
-
Improve test coverage for changes to inplace-updated catalogs.
- 796d191028bb 12.20 landed
- 65aae93c456a 13.16 landed
- 2d06bdbc0cc3 14.13 landed
- 3c6becd3d180 15.8 landed
- dd8008e8ec95 16.4 landed
- 0844b3968985 17.0 landed
-
Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.
- e2eefb97e31a 12.20 landed
- 1a6d65b64e84 13.16 landed
- 578db9c9257d 14.13 landed
- a338e41374e4 15.8 landed
- 480b58fabd35 16.4 landed
- 0cecc908e974 17.0 landed
-
Lock owned sequences during ALTER TABLE SET { LOGGED | UNLOGGED }.
- 24561b498f11 15.8 landed
- 112d055706bf 16.4 landed
- f88cdb36c457 17.0 landed
-
Make TAP todo_start effects the same under Meson and prove_check.
- 288426902ee5 16.4 landed
- 22a4b104ba70 17.0 landed
-
Add an injection_points isolation test suite.
- c35f419d6efb 17.0 landed
-
Add wait event type "InjectionPoint", a custom type like "Extension".
- bb93640a681c 17.0 landed
-
Create waitfuncs.c for pg_isolation_test_session_is_blocked().
- abfbd13af0e9 17.0 landed
-
Rework planning and execution of UPDATE and DELETE.
- 86dc90056dfd 14.0 cited
Attachments
- inplace005-UNEXPECTEDPASS-tap-meson-v2.patch (text/plain) patch v2
- inplace010-tests-v2.patch (text/plain) patch v2
- inplace040-waitfuncs-v2.patch (text/plain) patch v2
- inplace050-tests-inj-v2.patch (text/plain) patch v2
- inplace060-nodeModifyTable-comments-v2.patch (text/plain) patch v2
- inplace065-lock-SequenceChangePersistence-v2.patch (text/plain) patch v2
- inplace071-lock-SetRelationHasSubclass-v2.patch (text/plain) patch v2
- inplace075-lock-heap_create-v2.patch (text/plain) patch v2
- inplace080-catcache-detoast-inplace-stale-v2.patch (text/plain) patch v2
- inplace090-LOCKTAG_TUPLE-eoxact-v2.patch (text/plain) patch v2
- inplace110-successors-v2.patch (text/plain) patch v2
- inplace120-locktag-v2.patch (text/plain) patch v2
On Thu, Jun 06, 2024 at 09:48:51AM -0400, Robert Haas wrote: > On Wed, Jun 5, 2024 at 2:17 PM Noah Misch <noah@leadboat.com> wrote: > > Starting 2024-06-10, I plan to push the first seven of the ten patches: > > > > inplace005-UNEXPECTEDPASS-tap-meson-v1.patch > > inplace010-tests-v1.patch > > inplace040-waitfuncs-v1.patch > > inplace050-tests-inj-v1.patch > > inplace060-nodeModifyTable-comments-v1.patch > > Those five just deal in tests, test infrastructure, and comments. > > inplace070-rel-locks-missing-v1.patch > > Main risk is new DDL deadlocks. > > inplace080-catcache-detoast-inplace-stale-v1.patch > > If it fails to fix the bug it targets, I expect it's a no-op rather than > > breaking things. > > > > I'll leave the last three of the ten needing review. Those three are beyond > > my skill to self-certify. > > It's not this patch set's fault, but I'm not very pleased to see that > the injection point wait events have been shoehorned into the > "Extension" category I've replied on that branch of the thread. > I think that the comments and commit messages in this patch set could, > in some places, use improvement. For instance, > inplace060-nodeModifyTable-comments-v1.patch reflows a bunch of > comments, which makes it hard to see what actually changed, and the > commit message doesn't tell you, either. A good bit of it seems to be > changing "a view" to "a view INSTEAD OF trigger" or "a view having an > INSTEAD OF trigger," but the reasoning behind that change is not > spelled out anywhere. The reader is left to guess what the other case > is and why the same principles don't apply to it. I don't doubt that > the new comments are more correct than the old ones, but I expect > future patch authors to have difficulty maintaining that state of > affairs. The two kinds are trigger-updatable views and auto-updatable views. I've added sentences about that to the nodeModifyTable.c header comment. One could argue for dropping the INSTEAD OF comment changes outside of the header. > Similarly, inplace070-rel-locks-missing-v1.patch adds no comments. > IMHO, the commit message also isn't very informative. It disclaims > knowledge of what bug it's fixing, while at the same time leaving the > reader to figure out for themselves how the behavior has changed. > Consequently, I expect writing the release notes for a release > including this patch to be difficult: "We added some locks that block > ... something ... in some circumstances ... to prevent ... something." > It's not really the job of the release note author to fill in those > blanks, but rather of the patch author or committer. I don't want to I had been thinking release notes should just say "Add missing DDL lock acquisitions". One can cure a breach of our locking standards without proving some specific bad outcome. However, one could counter that commands like GRANT follow a different standard, and perhaps SetRelationHasSubclass() should use the GRANT standard. Hence, I researched the bugs this fixes and split inplace070-rel-locks-missing into three patches: 1. [inplace065-lock-SequenceChangePersistence] Lock in SequenceChangePersistence(), where the omission can lose nextval() increments of the sequence. 2. [inplace071-lock-SetRelationHasSubclass] Lock in SetRelationHasSubclass(). This one has only minor benefits; see the new commit message. A fair alternative would be tuple-level locking in inplace120-locktag, like that patch adds to GRANT. That might avoid some deadlocks. I feel like the minor benefits justify the way I chose, but it's a weak preference. 3. [inplace075-lock-heap_create] Add to heap creation: > overburden the act of fixing bugs, but I just feel like more > explanation is needed here. When I see for example that we're adding a > lock acquisition to the end of heap_create(), I can't help but wonder > if it's really true that we don't take a lock on a just-created > relation today. I'm certainly under the impression that we lock > newly-created, uncommitted relations, and a quick test seems to > confirm that. I don't quite know whether that happens, but evidently > this call is guarding against something more subtle than a categorical > failure to lock a relation on creation so I think there should be a > comment explaining what that thing is. I've covered that in the new log message. To lock as early as possible, I've moved this up a layer, to just after relid assignment. One could argue this change belongs in inplace120 rather than its own patch, since it's only here to eliminate a harmless exception to the rule inplace120 asserts. I've removed the update_relispartition() that appeared in inplace070-rel-locks-missing-v1.patch. Only an older, unpublished draft of the rules (that inplace110-successors adds to README.tuplock) required that lock. The lock might be worthwhile for avoiding "tuple concurrently updated", but it's out of scope for $SUBJECT. > It's also quite surprising that SetRelationHasSubclass() says "take X > lock before calling" and 2 of 4 callers just don't. I guess that's how > it is. But shouldn't we then have an assertion inside that function to > guard against future mistakes? If the reason why we failed to add this Works for me. Done. I've moved the LockHeldByMe() change from inplace110-successors to this patch, since the assertion wants it. > initially is discernible from the commit messages that introduced the > bug, it would be nice to mention what it seems to have been; if not, > it would at least be nice to mention the offending commit(s). I'm also Done. > a bit worried that this is going to cause deadlocks, but I suppose if > it does, that's still better than the status quo. > > IsInplaceUpdateOid's header comment says IsInplaceUpdateRelation > instead of IsInplaceUpdateOid. Fixed. > inplace080-catcache-detoast-inplace-stale-v1.patch seems like another > place where spelling out the rationale in more detail would be helpful > to future readers; for instance, the commit message says that > PgDatabaseToastTable is the only one affected, but it doesn't say why > the others are not, or why this one is. The lengthy comment in I've updated the commit message to answer that. > CatalogCacheCreateEntry is also difficult to correlate with the code > which follows. I can't guess whether the two cases called out in the > comment always needed to be handled and were handled save only for > in-place updates, and thus the comment changes were simply taking the > opportunity to elaborate on the existing comments; or whether one of > those cases is preexisting and the other arises from the desire to > handle inplace updates. It could be helpful to mention relevant > identifiers from the code in the comment text e.g. > "systable_recheck_tuple detects ordinary updates by noting changes to > the tuple's visibility information, while the equalTuple() case > detects inplace updates." The patch was elaborating on existing comments. Reading the patch again today, the elaboration no longer feels warranted. Hence, I've rewritten that comment addition. I've included identifiers, and the patch no longer adds comment material orthogonal to inplace updates. Thanks, nm