pgsql: Fix temporary relation I/O statistics in single-user mode

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix temporary relation I/O statistics in single-user mode
Date: 2026-11-18 07:10:53
Message-ID: E1xTZoi-00000000Ctc-48Iq@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix temporary relation I/O statistics in single-user mode

Accessing temporary relations in single-user mode could trigger an
assertion failure in assertion-enabled builds. For example, CREATE
TEMP TABLE AS and CREATE TEMP SEQUENCE failed when recording relation
extension statistics. Without assertions, the statistics were still
collected internally but were not exposed in pg_stat_io.

The problem was that pgstat_tracks_io_object() incorrectly excluded
standalone backends from I/O tracking for temporary relations, even
though they use local buffers just like regular client backends.

Remove this exclusion to prevent the assertion failures and make the
statistics visible in pg_stat_io.

Backpatch to v16, where the incorrect exclusion was introduced in
commit 28e626bde00.

Author: Manuel Reyes Bravo <manuelreyesbravo(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/179487554022.104798.7544124224648387746@gmail.com
Backpatch-through: 16

Branch
------
REL_16_STABLE

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

Modified Files
--------------
src/backend/utils/activity/pgstat_io.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Previous Message Fujii Masao 2026-11-18 07:10:41 pgsql: Fix temporary relation I/O statistics in single-user mode