postgresql/src/include/storage
Noah Misch a338e41374 Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.
Commit 5b562644fe added a comment that
SetRelationHasSubclass() callers must hold this lock.  When commit
17f206fbc8 extended use of this column to
partitioned indexes, it didn't take the lock.  As the latter commit
message mentioned, we currently never reset a partitioned index to
relhassubclass=f.  That largely avoids harm from the lock omission.  The
cause for fixing this now is to unblock introducing a rule about locks
required to heap_update() a pg_class row.  This might cause more
deadlocks.  It gives minor user-visible benefits:

- If an ALTER INDEX SET TABLESPACE runs concurrently with ALTER TABLE
  ATTACH PARTITION or CREATE PARTITION OF, one transaction blocks
  instead of failing with "tuple concurrently updated".  (Many cases of
  DDL concurrency still fail that way.)

- Match ALTER INDEX ATTACH PARTITION in choosing to lock the index.

While not user-visible today, we'll need this if we ever make something
set the flag to false for a partitioned index, like ANALYZE does today
for tables.  Back-patch to v12 (all supported versions), the plan for
the commit relying on the new rule.  In back branches, add
LockOrStrongerHeldByMe() instead of adding a LockHeldByMe() parameter.

Reviewed (in an earlier version) by Robert Haas.

Discussion: https://postgr.es/m/20240611024525.9f.nmisch@google.com
2024-06-27 19:21:10 -07:00
..
.gitignore When trace_lwlocks is used, identify individual lwlocks by name. 2015-09-11 14:01:39 -04:00
backendid.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
barrier.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
block.h Remove some pointless code in block.h. 2022-03-03 19:15:38 -05:00
buf.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
buf_internals.h Ensure we use the correct spelling of "ensure" 2023-11-10 00:17:07 +13:00
buffile.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
bufmgr.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
bufpage.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
checksum.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
checksum_impl.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
condition_variable.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
copydir.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
dsm.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
dsm_impl.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
fd.h Revert recent changes with durable_rename_excl() 2022-04-28 13:08:16 +09:00
fileset.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
freespace.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
fsm_internals.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
indexfsm.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
ipc.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
item.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
itemid.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
itemptr.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
large_object.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
latch.h Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
lmgr.h Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX. 2024-06-27 19:21:10 -07:00
lock.h Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX. 2024-06-27 19:21:10 -07:00
lockdefs.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
lwlock.h lwlock: Fix quadratic behavior with very long wait lists 2024-01-18 11:12:31 +09:00
md.h Rethink PROCSIGNAL_BARRIER_SMGRRELEASE. 2022-05-07 16:32:10 +12:00
off.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_sema.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_shmem.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
pmsignal.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
predicate.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
predicate_internals.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
proc.h lwlock: Fix quadratic behavior with very long wait lists 2024-01-18 11:12:31 +09:00
procarray.h Improve heuristics for compressing the KnownAssignedXids array. 2022-11-29 15:43:17 -05:00
proclist.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
proclist_types.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
procsignal.h Fix DROP {DATABASE,TABLESPACE} on Windows. 2022-02-12 10:21:23 +13:00
reinit.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
relfilenode.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
s_lock.h Allow use of __sync_lock_test_and_set for spinlocks on any machine. 2022-11-02 17:37:26 -04:00
sharedfileset.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
shm_mq.h shm_mq_sendv: Fix flushing bug when receiver not yet attached. 2022-05-31 08:46:54 -04:00
shm_toc.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
shmem.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
sinval.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
sinvaladt.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
smgr.h Rethink PROCSIGNAL_BARRIER_SMGRRELEASE. 2022-05-07 16:32:10 +12:00
spin.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
standby.h Fix MVCC bug with prepared xact with subxacts on standby 2024-06-27 21:10:31 +03:00
standbydefs.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
sync.h Update copyright for 2022 2022-01-07 19:04:57 -05:00