pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.
6+ messages / 1 participants
[nested] [flat]

* pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.
@ 2024-06-28 02:26 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Noah Misch @ 2024-06-28 02:26 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.

Commit 5b562644fec696977df4a82790064e8287927891 added a comment that
SetRelationHasSubclass() callers must hold this lock.  When commit
17f206fbc824d2b4b14480199ca9ff7dea417eda 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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0cecc908e9749101b5e93ba58d76a62c9f226f9e

Modified Files
--------------
src/backend/catalog/index.c      |  1 +
src/backend/commands/indexcmds.c |  3 +++
src/backend/commands/tablecmds.c | 16 ++++++++++++++--
src/backend/storage/lmgr/lmgr.c  | 36 +++++++++++++-----------------------
src/backend/storage/lmgr/lock.c  | 30 ++++++++++++++++++++++++++----
src/include/storage/lmgr.h       |  2 ++
src/include/storage/lock.h       |  3 ++-
7 files changed, 61 insertions(+), 30 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.
@ 2024-06-28 02:26 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Noah Misch @ 2024-06-28 02:26 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.

Commit 5b562644fec696977df4a82790064e8287927891 added a comment that
SetRelationHasSubclass() callers must hold this lock.  When commit
17f206fbc824d2b4b14480199ca9ff7dea417eda 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

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/480b58fabd353015319f6621ff8c351bf3a6d520

Modified Files
--------------
src/backend/catalog/index.c      |  1 +
src/backend/commands/indexcmds.c |  3 +++
src/backend/commands/tablecmds.c | 16 +++++++++++++--
src/backend/storage/lmgr/lmgr.c  | 40 ++++++++++++++++--------------------
src/backend/storage/lmgr/lock.c  | 44 +++++++++++++++++++++++++++++++++++-----
src/include/storage/lmgr.h       |  2 ++
src/include/storage/lock.h       |  1 +
7 files changed, 77 insertions(+), 30 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.
@ 2024-06-28 02:26 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Noah Misch @ 2024-06-28 02:26 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.

Commit 5b562644fec696977df4a82790064e8287927891 added a comment that
SetRelationHasSubclass() callers must hold this lock.  When commit
17f206fbc824d2b4b14480199ca9ff7dea417eda 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

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a338e41374e4cf7efded6839ac58a60916b31ba7

Modified Files
--------------
src/backend/catalog/index.c      |  1 +
src/backend/commands/indexcmds.c |  3 +++
src/backend/commands/tablecmds.c | 16 +++++++++++++--
src/backend/storage/lmgr/lmgr.c  | 40 ++++++++++++++++--------------------
src/backend/storage/lmgr/lock.c  | 44 +++++++++++++++++++++++++++++++++++-----
src/include/storage/lmgr.h       |  2 ++
src/include/storage/lock.h       |  1 +
7 files changed, 77 insertions(+), 30 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.
@ 2024-06-28 02:26 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Noah Misch @ 2024-06-28 02:26 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.

Commit 5b562644fec696977df4a82790064e8287927891 added a comment that
SetRelationHasSubclass() callers must hold this lock.  When commit
17f206fbc824d2b4b14480199ca9ff7dea417eda 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

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/578db9c9257de00ee695d670fb7d62b295467fe8

Modified Files
--------------
src/backend/catalog/index.c      |  1 +
src/backend/commands/indexcmds.c |  3 +++
src/backend/commands/tablecmds.c | 16 +++++++++++++--
src/backend/storage/lmgr/lmgr.c  | 40 ++++++++++++++++--------------------
src/backend/storage/lmgr/lock.c  | 44 +++++++++++++++++++++++++++++++++++-----
src/include/storage/lmgr.h       |  2 ++
src/include/storage/lock.h       |  1 +
7 files changed, 77 insertions(+), 30 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.
@ 2024-06-28 02:26 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Noah Misch @ 2024-06-28 02:26 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.

Commit 5b562644fec696977df4a82790064e8287927891 added a comment that
SetRelationHasSubclass() callers must hold this lock.  When commit
17f206fbc824d2b4b14480199ca9ff7dea417eda 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

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1a6d65b64e8495280862f5757062eb844d134488

Modified Files
--------------
src/backend/catalog/index.c      |  1 +
src/backend/commands/indexcmds.c |  3 +++
src/backend/commands/tablecmds.c | 16 +++++++++++++--
src/backend/storage/lmgr/lmgr.c  | 40 ++++++++++++++++--------------------
src/backend/storage/lmgr/lock.c  | 44 +++++++++++++++++++++++++++++++++++-----
src/include/storage/lmgr.h       |  2 ++
src/include/storage/lock.h       |  1 +
7 files changed, 77 insertions(+), 30 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.
@ 2024-06-28 02:26 Noah Misch <noah@leadboat.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Noah Misch @ 2024-06-28 02:26 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.

Commit 5b562644fec696977df4a82790064e8287927891 added a comment that
SetRelationHasSubclass() callers must hold this lock.  When commit
17f206fbc824d2b4b14480199ca9ff7dea417eda 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

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e2eefb97e31a64b48bb22fe53d0101586891d01f

Modified Files
--------------
src/backend/catalog/index.c      |  1 +
src/backend/commands/indexcmds.c |  3 +++
src/backend/commands/tablecmds.c | 16 +++++++++++++--
src/backend/storage/lmgr/lmgr.c  | 40 ++++++++++++++++--------------------
src/backend/storage/lmgr/lock.c  | 44 +++++++++++++++++++++++++++++++++++-----
src/include/storage/lmgr.h       |  2 ++
src/include/storage/lock.h       |  1 +
7 files changed, 77 insertions(+), 30 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2024-06-28 02:26 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-06-28 02:26 pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX. Noah Misch <noah@leadboat.com>
2024-06-28 02:26 pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX. Noah Misch <noah@leadboat.com>
2024-06-28 02:26 pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX. Noah Misch <noah@leadboat.com>
2024-06-28 02:26 pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX. Noah Misch <noah@leadboat.com>
2024-06-28 02:26 pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX. Noah Misch <noah@leadboat.com>
2024-06-28 02:26 pgsql: Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX. Noah Misch <noah@leadboat.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox