pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Ensure we have a snapshot when updating pg_index entries.
8+ messages / 1 participants
[nested] [flat]
* pgsql: Ensure we have a snapshot when updating pg_index entries.
@ 2024-09-26 20:51 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Bossart @ 2024-09-26 20:51 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Ensure we have a snapshot when updating pg_index entries.
Creating, reindexing, and dropping an index concurrently could
entail accessing pg_index's TOAST table, which was recently added
in commit b52c4fc3c0. These code paths start and commit their own
transactions, but they do not always set an active snapshot. This
rightfully leads to assertion failures and ERRORs when trying to
access pg_index's TOAST table, such as the following:
ERROR: cannot fetch toast data without an active snapshot
To fix, push an active snapshot just before each section of code
that might require accessing pg_index's TOAST table, and pop it
shortly afterwards.
Reported-by: Alexander Lakhin
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/a97d7401-e7c9-f771-6a00-037379f0a8bb%40gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/b52adbad46740524cbfbffaeb202b01a2c16202a
Modified Files
--------------
src/backend/catalog/index.c | 21 +++++++++++++++++++++
src/backend/commands/indexcmds.c | 24 ++++++++++++++++++++++++
src/test/regress/expected/indexing.out | 15 +++++++++++++++
src/test/regress/sql/indexing.sql | 16 ++++++++++++++++
4 files changed, 76 insertions(+)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Ensure we have a snapshot when updating pg_index in index_drop()
@ 2024-10-28 21:45 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Bossart @ 2024-10-28 21:45 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Ensure we have a snapshot when updating pg_index in index_drop().
I assumed that all index_drop() callers set an active snapshot
beforehand, but that is evidently not true. One counterexample is
autovacuum, which doesn't set an active snapshot when cleaning up
orphan temp indexes. To fix, unconditionally push an active
snapshot before updating pg_index in index_drop().
Oversight in commit b52adbad46.
Reported-by: Masahiko Sawada
Reviewed-by: Stepan Neretin, Masahiko Sawada
Discussion: https://postgr.es/m/CAD21AoBgF9etQrXbN9or_YHsmBRJHHNUEkhHp9rGK9CyQv5aTQ%40mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/70b9adb98eab42bc12ddeea863be335b21b55675
Modified Files
--------------
src/backend/catalog/index.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Ensure we have a snapshot when updating various system catalogs.
@ 2025-05-30 20:18 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Bossart @ 2025-05-30 20:18 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Ensure we have a snapshot when updating various system catalogs.
A few places that access system catalogs don't set up an active
snapshot before potentially accessing their TOAST tables. To fix,
push an active snapshot just before each section of code that might
require accessing one of these TOAST tables, and pop it shortly
afterwards. While at it, this commit adds some rather strict
assertions in an attempt to prevent such issues in the future.
Commit 16bf24e0e4 recently removed pg_replication_origin's TOAST
table in order to fix the same problem for that catalog. On the
back-branches, those bugs are left in place. We cannot easily
remove a catalog's TOAST table on released major versions, and only
replication origins with extremely long names are affected. Given
the low severity of the issue, fixing older versions doesn't seem
worth the trouble of significantly modifying the patch.
Also, on v13 and v14, the aforementioned strict assertions have
been omitted because commit 2776922201, which added
HaveRegisteredOrActiveSnapshot(), was not back-patched. While we
could probably back-patch it now, I've opted against it because it
seems unlikely that new TOAST snapshot issues will be introduced in
the oldest supported versions.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/18127-fe54b6a667f29658%40postgresql.org
Discussion: https://postgr.es/m/18309-c0bf914950c46692%40postgresql.org
Discussion: https://postgr.es/m/ZvMSUPOqUU-VNADN%40nathan
Backpatch-through: 13
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/ddfcfb7cec686cc768795d025344d412b5fcc673
Modified Files
--------------
src/backend/access/heap/heapam.c | 41 ++++++++++++++++++++++++++++++++
src/backend/commands/indexcmds.c | 8 +++++++
src/backend/commands/tablecmds.c | 8 +++++++
src/backend/postmaster/autovacuum.c | 7 ++++++
src/backend/replication/logical/worker.c | 24 +++++++++++++++++++
5 files changed, 88 insertions(+)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Ensure we have a snapshot when updating various system catalogs.
@ 2025-05-30 20:18 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Bossart @ 2025-05-30 20:18 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Ensure we have a snapshot when updating various system catalogs.
A few places that access system catalogs don't set up an active
snapshot before potentially accessing their TOAST tables. To fix,
push an active snapshot just before each section of code that might
require accessing one of these TOAST tables, and pop it shortly
afterwards. While at it, this commit adds some rather strict
assertions in an attempt to prevent such issues in the future.
Commit 16bf24e0e4 recently removed pg_replication_origin's TOAST
table in order to fix the same problem for that catalog. On the
back-branches, those bugs are left in place. We cannot easily
remove a catalog's TOAST table on released major versions, and only
replication origins with extremely long names are affected. Given
the low severity of the issue, fixing older versions doesn't seem
worth the trouble of significantly modifying the patch.
Also, on v13 and v14, the aforementioned strict assertions have
been omitted because commit 2776922201, which added
HaveRegisteredOrActiveSnapshot(), was not back-patched. While we
could probably back-patch it now, I've opted against it because it
seems unlikely that new TOAST snapshot issues will be introduced in
the oldest supported versions.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/18127-fe54b6a667f29658%40postgresql.org
Discussion: https://postgr.es/m/18309-c0bf914950c46692%40postgresql.org
Discussion: https://postgr.es/m/ZvMSUPOqUU-VNADN%40nathan
Backpatch-through: 13
Branch
------
REL_13_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/b7ba2c0308ce2010c428327d7f03616dc9068f15
Modified Files
--------------
src/backend/commands/indexcmds.c | 8 ++++++++
src/backend/postmaster/autovacuum.c | 7 +++++++
2 files changed, 15 insertions(+)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Ensure we have a snapshot when updating various system catalogs.
@ 2025-05-30 20:18 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Bossart @ 2025-05-30 20:18 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Ensure we have a snapshot when updating various system catalogs.
A few places that access system catalogs don't set up an active
snapshot before potentially accessing their TOAST tables. To fix,
push an active snapshot just before each section of code that might
require accessing one of these TOAST tables, and pop it shortly
afterwards. While at it, this commit adds some rather strict
assertions in an attempt to prevent such issues in the future.
Commit 16bf24e0e4 recently removed pg_replication_origin's TOAST
table in order to fix the same problem for that catalog. On the
back-branches, those bugs are left in place. We cannot easily
remove a catalog's TOAST table on released major versions, and only
replication origins with extremely long names are affected. Given
the low severity of the issue, fixing older versions doesn't seem
worth the trouble of significantly modifying the patch.
Also, on v13 and v14, the aforementioned strict assertions have
been omitted because commit 2776922201, which added
HaveRegisteredOrActiveSnapshot(), was not back-patched. While we
could probably back-patch it now, I've opted against it because it
seems unlikely that new TOAST snapshot issues will be introduced in
the oldest supported versions.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/18127-fe54b6a667f29658%40postgresql.org
Discussion: https://postgr.es/m/18309-c0bf914950c46692%40postgresql.org
Discussion: https://postgr.es/m/ZvMSUPOqUU-VNADN%40nathan
Backpatch-through: 13
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/706054b11b959c865c0c7935c34d92370d7168d4
Modified Files
--------------
src/backend/access/heap/heapam.c | 29 +++++++++++++++++++++++++++++
src/backend/commands/indexcmds.c | 2 +-
src/backend/commands/tablecmds.c | 8 ++++++++
src/backend/postmaster/autovacuum.c | 7 +++++++
src/backend/replication/logical/worker.c | 24 ++++++++++++++++++++++++
5 files changed, 69 insertions(+), 1 deletion(-)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Ensure we have a snapshot when updating various system catalogs.
@ 2025-05-30 20:18 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Bossart @ 2025-05-30 20:18 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Ensure we have a snapshot when updating various system catalogs.
A few places that access system catalogs don't set up an active
snapshot before potentially accessing their TOAST tables. To fix,
push an active snapshot just before each section of code that might
require accessing one of these TOAST tables, and pop it shortly
afterwards. While at it, this commit adds some rather strict
assertions in an attempt to prevent such issues in the future.
Commit 16bf24e0e4 recently removed pg_replication_origin's TOAST
table in order to fix the same problem for that catalog. On the
back-branches, those bugs are left in place. We cannot easily
remove a catalog's TOAST table on released major versions, and only
replication origins with extremely long names are affected. Given
the low severity of the issue, fixing older versions doesn't seem
worth the trouble of significantly modifying the patch.
Also, on v13 and v14, the aforementioned strict assertions have
been omitted because commit 2776922201, which added
HaveRegisteredOrActiveSnapshot(), was not back-patched. While we
could probably back-patch it now, I've opted against it because it
seems unlikely that new TOAST snapshot issues will be introduced in
the oldest supported versions.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/18127-fe54b6a667f29658%40postgresql.org
Discussion: https://postgr.es/m/18309-c0bf914950c46692%40postgresql.org
Discussion: https://postgr.es/m/ZvMSUPOqUU-VNADN%40nathan
Backpatch-through: 13
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/fe8ea7a2a89342ecc36a054b2f328c4d8e56f9ae
Modified Files
--------------
src/backend/access/heap/heapam.c | 41 ++++++++++++++++++++++++++++++++
src/backend/commands/indexcmds.c | 8 +++++++
src/backend/commands/tablecmds.c | 8 +++++++
src/backend/postmaster/autovacuum.c | 7 ++++++
src/backend/replication/logical/worker.c | 24 +++++++++++++++++++
5 files changed, 88 insertions(+)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Ensure we have a snapshot when updating various system catalogs.
@ 2025-05-30 20:18 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Bossart @ 2025-05-30 20:18 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Ensure we have a snapshot when updating various system catalogs.
A few places that access system catalogs don't set up an active
snapshot before potentially accessing their TOAST tables. To fix,
push an active snapshot just before each section of code that might
require accessing one of these TOAST tables, and pop it shortly
afterwards. While at it, this commit adds some rather strict
assertions in an attempt to prevent such issues in the future.
Commit 16bf24e0e4 recently removed pg_replication_origin's TOAST
table in order to fix the same problem for that catalog. On the
back-branches, those bugs are left in place. We cannot easily
remove a catalog's TOAST table on released major versions, and only
replication origins with extremely long names are affected. Given
the low severity of the issue, fixing older versions doesn't seem
worth the trouble of significantly modifying the patch.
Also, on v13 and v14, the aforementioned strict assertions have
been omitted because commit 2776922201, which added
HaveRegisteredOrActiveSnapshot(), was not back-patched. While we
could probably back-patch it now, I've opted against it because it
seems unlikely that new TOAST snapshot issues will be introduced in
the oldest supported versions.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/18127-fe54b6a667f29658%40postgresql.org
Discussion: https://postgr.es/m/18309-c0bf914950c46692%40postgresql.org
Discussion: https://postgr.es/m/ZvMSUPOqUU-VNADN%40nathan
Backpatch-through: 13
Branch
------
REL_16_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/24135398f1e18e7779fd5052af8399c9d6bb5ff7
Modified Files
--------------
src/backend/access/heap/heapam.c | 41 ++++++++++++++++++++++++++++++++
src/backend/commands/indexcmds.c | 8 +++++++
src/backend/commands/tablecmds.c | 8 +++++++
src/backend/postmaster/autovacuum.c | 7 ++++++
src/backend/replication/logical/worker.c | 24 +++++++++++++++++++
5 files changed, 88 insertions(+)
^ permalink raw reply [nested|flat] 8+ messages in thread
* pgsql: Ensure we have a snapshot when updating various system catalogs.
@ 2025-05-30 20:18 Nathan Bossart <nathan@postgresql.org>
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Bossart @ 2025-05-30 20:18 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Ensure we have a snapshot when updating various system catalogs.
A few places that access system catalogs don't set up an active
snapshot before potentially accessing their TOAST tables. To fix,
push an active snapshot just before each section of code that might
require accessing one of these TOAST tables, and pop it shortly
afterwards. While at it, this commit adds some rather strict
assertions in an attempt to prevent such issues in the future.
Commit 16bf24e0e4 recently removed pg_replication_origin's TOAST
table in order to fix the same problem for that catalog. On the
back-branches, those bugs are left in place. We cannot easily
remove a catalog's TOAST table on released major versions, and only
replication origins with extremely long names are affected. Given
the low severity of the issue, fixing older versions doesn't seem
worth the trouble of significantly modifying the patch.
Also, on v13 and v14, the aforementioned strict assertions have
been omitted because commit 2776922201, which added
HaveRegisteredOrActiveSnapshot(), was not back-patched. While we
could probably back-patch it now, I've opted against it because it
seems unlikely that new TOAST snapshot issues will be introduced in
the oldest supported versions.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/18127-fe54b6a667f29658%40postgresql.org
Discussion: https://postgr.es/m/18309-c0bf914950c46692%40postgresql.org
Discussion: https://postgr.es/m/ZvMSUPOqUU-VNADN%40nathan
Backpatch-through: 13
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/b65be6ef00e2bfad7317cc32e33333e8f3a26642
Modified Files
--------------
src/backend/commands/indexcmds.c | 8 ++++++++
src/backend/commands/tablecmds.c | 8 ++++++++
src/backend/postmaster/autovacuum.c | 7 +++++++
3 files changed, 23 insertions(+)
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2025-05-30 20:18 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-09-26 20:51 pgsql: Ensure we have a snapshot when updating pg_index entries. Nathan Bossart <nathan@postgresql.org>
2024-10-28 21:45 pgsql: Ensure we have a snapshot when updating pg_index in index_drop() Nathan Bossart <nathan@postgresql.org>
2025-05-30 20:18 pgsql: Ensure we have a snapshot when updating various system catalogs. Nathan Bossart <nathan@postgresql.org>
2025-05-30 20:18 pgsql: Ensure we have a snapshot when updating various system catalogs. Nathan Bossart <nathan@postgresql.org>
2025-05-30 20:18 pgsql: Ensure we have a snapshot when updating various system catalogs. Nathan Bossart <nathan@postgresql.org>
2025-05-30 20:18 pgsql: Ensure we have a snapshot when updating various system catalogs. Nathan Bossart <nathan@postgresql.org>
2025-05-30 20:18 pgsql: Ensure we have a snapshot when updating various system catalogs. Nathan Bossart <nathan@postgresql.org>
2025-05-30 20:18 pgsql: Ensure we have a snapshot when updating various system catalogs. Nathan Bossart <nathan@postgresql.org>
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