pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY
6+ messages / 1 participants
[nested] [flat]

* pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY
@ 2026-11-20 04:47  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2026-11-20 04:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Pin relations in phase 1 of REINDEX CONCURRENTLY

Phase 1 of ReindexRelationConcurrently() evaluates index expressions and
predicates when computing the safety of each index and when creating the
definition of each new index.  These may call functions run as the table
owner.

The old and new indexes processed in the previous iterations of the loop
were closed at this stage.  Hence, a function was able to drop one of
them or reindex one of the new indexes, leading to an assertion failure
in the build phase, or to an internal error with a dropped index
committed.

The relations opened in phase 1 are now kept opened until the session
locks are taken, so as DDLs on them are blocked by CheckTableNotInUse().
The build and validation phases already pin the relations, and the
protections in build phase limit the damage to an ERROR.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Discussion: https://postgr.es/m/aver6A1EQEd2FaKq@paquier.xyz
Backpatch-through: 15

Branch
------
master

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

Modified Files
--------------
src/backend/commands/indexcmds.c           | 28 ++++++++++++++++++----
src/test/regress/expected/create_index.out | 37 +++++++++++++++++++++++++++++-
src/test/regress/sql/create_index.sql      | 26 ++++++++++++++++++++-
3 files changed, 84 insertions(+), 7 deletions(-)



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

* pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY
@ 2026-11-20 04:47  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2026-11-20 04:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Pin relations in phase 1 of REINDEX CONCURRENTLY

Phase 1 of ReindexRelationConcurrently() evaluates index expressions and
predicates when computing the safety of each index and when creating the
definition of each new index.  These may call functions run as the table
owner.

The old and new indexes processed in the previous iterations of the loop
were closed at this stage.  Hence, a function was able to drop one of
them or reindex one of the new indexes, leading to an assertion failure
in the build phase, or to an internal error with a dropped index
committed.

The relations opened in phase 1 are now kept opened until the session
locks are taken, so as DDLs on them are blocked by CheckTableNotInUse().
The build and validation phases already pin the relations, and the
protections in build phase limit the damage to an ERROR.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Discussion: https://postgr.es/m/aver6A1EQEd2FaKq@paquier.xyz
Backpatch-through: 15

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4139fc83f4fa8f961a9adbc365770c3294fc897f

Modified Files
--------------
src/backend/commands/indexcmds.c           | 28 ++++++++++++++++++----
src/test/regress/expected/create_index.out | 37 +++++++++++++++++++++++++++++-
src/test/regress/sql/create_index.sql      | 26 ++++++++++++++++++++-
3 files changed, 84 insertions(+), 7 deletions(-)



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

* pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY
@ 2026-11-20 04:47  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2026-11-20 04:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Pin relations in phase 1 of REINDEX CONCURRENTLY

Phase 1 of ReindexRelationConcurrently() evaluates index expressions and
predicates when computing the safety of each index and when creating the
definition of each new index.  These may call functions run as the table
owner.

The old and new indexes processed in the previous iterations of the loop
were closed at this stage.  Hence, a function was able to drop one of
them or reindex one of the new indexes, leading to an assertion failure
in the build phase, or to an internal error with a dropped index
committed.

The relations opened in phase 1 are now kept opened until the session
locks are taken, so as DDLs on them are blocked by CheckTableNotInUse().
The build and validation phases already pin the relations, and the
protections in build phase limit the damage to an ERROR.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Discussion: https://postgr.es/m/aver6A1EQEd2FaKq@paquier.xyz
Backpatch-through: 15

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9e612947eac3a296660823210db1881ad0819960

Modified Files
--------------
src/backend/commands/indexcmds.c           | 28 ++++++++++++++++++----
src/test/regress/expected/create_index.out | 37 +++++++++++++++++++++++++++++-
src/test/regress/sql/create_index.sql      | 26 ++++++++++++++++++++-
3 files changed, 84 insertions(+), 7 deletions(-)



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

* pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY
@ 2026-11-20 04:47  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2026-11-20 04:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Pin relations in phase 1 of REINDEX CONCURRENTLY

Phase 1 of ReindexRelationConcurrently() evaluates index expressions and
predicates when computing the safety of each index and when creating the
definition of each new index.  These may call functions run as the table
owner.

The old and new indexes processed in the previous iterations of the loop
were closed at this stage.  Hence, a function was able to drop one of
them or reindex one of the new indexes, leading to an assertion failure
in the build phase, or to an internal error with a dropped index
committed.

The relations opened in phase 1 are now kept opened until the session
locks are taken, so as DDLs on them are blocked by CheckTableNotInUse().
The build and validation phases already pin the relations, and the
protections in build phase limit the damage to an ERROR.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Discussion: https://postgr.es/m/aver6A1EQEd2FaKq@paquier.xyz
Backpatch-through: 15

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/116bd1a912090ef9cd56b87b79eb1bf8ab48a1dd

Modified Files
--------------
src/backend/commands/indexcmds.c           | 28 ++++++++++++++++++----
src/test/regress/expected/create_index.out | 37 +++++++++++++++++++++++++++++-
src/test/regress/sql/create_index.sql      | 26 ++++++++++++++++++++-
3 files changed, 84 insertions(+), 7 deletions(-)



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

* pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY
@ 2026-11-20 04:47  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2026-11-20 04:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Pin relations in phase 1 of REINDEX CONCURRENTLY

Phase 1 of ReindexRelationConcurrently() evaluates index expressions and
predicates when computing the safety of each index and when creating the
definition of each new index.  These may call functions run as the table
owner.

The old and new indexes processed in the previous iterations of the loop
were closed at this stage.  Hence, a function was able to drop one of
them or reindex one of the new indexes, leading to an assertion failure
in the build phase, or to an internal error with a dropped index
committed.

The relations opened in phase 1 are now kept opened until the session
locks are taken, so as DDLs on them are blocked by CheckTableNotInUse().
The build and validation phases already pin the relations, and the
protections in build phase limit the damage to an ERROR.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Discussion: https://postgr.es/m/aver6A1EQEd2FaKq@paquier.xyz
Backpatch-through: 15

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/435fa54b0d77403e71e7a529af3472e06ca6e4d4

Modified Files
--------------
src/backend/commands/indexcmds.c           | 28 ++++++++++++++++++----
src/test/regress/expected/create_index.out | 37 +++++++++++++++++++++++++++++-
src/test/regress/sql/create_index.sql      | 26 ++++++++++++++++++++-
3 files changed, 84 insertions(+), 7 deletions(-)



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

* pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY
@ 2026-11-20 04:47  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2026-11-20 04:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Pin relations in phase 1 of REINDEX CONCURRENTLY

Phase 1 of ReindexRelationConcurrently() evaluates index expressions and
predicates when computing the safety of each index and when creating the
definition of each new index.  These may call functions run as the table
owner.

The old and new indexes processed in the previous iterations of the loop
were closed at this stage.  Hence, a function was able to drop one of
them or reindex one of the new indexes, leading to an assertion failure
in the build phase, or to an internal error with a dropped index
committed.

The relations opened in phase 1 are now kept opened until the session
locks are taken, so as DDLs on them are blocked by CheckTableNotInUse().
The build and validation phases already pin the relations, and the
protections in build phase limit the damage to an ERROR.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Shihao Zhong <zhong950419@gmail.com>
Discussion: https://postgr.es/m/aver6A1EQEd2FaKq@paquier.xyz
Backpatch-through: 15

Branch
------
REL_15_STABLE

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

Modified Files
--------------
src/backend/commands/indexcmds.c           | 28 ++++++++++++++++++----
src/test/regress/expected/create_index.out | 37 +++++++++++++++++++++++++++++-
src/test/regress/sql/create_index.sql      | 26 ++++++++++++++++++++-
3 files changed, 84 insertions(+), 7 deletions(-)



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


end of thread, other threads:[~2026-11-20 04:47 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 04:47 pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY Michael Paquier <michael@paquier.xyz>
2026-11-20 04:47 pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY Michael Paquier <michael@paquier.xyz>
2026-11-20 04:47 pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY Michael Paquier <michael@paquier.xyz>
2026-11-20 04:47 pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY Michael Paquier <michael@paquier.xyz>
2026-11-20 04:47 pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY Michael Paquier <michael@paquier.xyz>
2026-11-20 04:47 pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY Michael Paquier <michael@paquier.xyz>

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