postgres.git / summary / log / commit / refs

commit    e9b2d85c145d0f9132b7c9eebc2bde0b343ab87b
Author:   Fujii Masao <fujii@postgresql.org>
Date:     Wed Nov 18 07:08:58 2026 +0000

    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@gmail.com>
    Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
    Discussion: https://postgr.es/m/179487554022.104798.7544124224648387746@gmail.com
    Backpatch-through: 16


src/backend/utils/activity/pgstat_io.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/backend/utils/activity/pgstat_io.c b/src/backend/utils/activity/pgstat_io.c index 9d6e0673827..82939498747 100644 --- a/src/backend/utils/activity/pgstat_io.c +++ b/src/backend/utils/activity/pgstat_io.c @@ -376,16 +376,16 @@ pgstat_tracks_io_object(BackendType bktype, IOObject io_object, return false; /* - * In core Postgres, only regular backends and WAL Sender processes - * executing queries will use local buffers and operate on temporary - * relations. Parallel workers will not use local buffers (see - * InitLocalBuffers()); however, extensions leveraging background workers - * have no such limitation, so track IO on IOOBJECT_TEMP_RELATION for - * BackendType B_BG_WORKER. + * In core Postgres, only regular backends, WAL Sender processes executing + * queries and standalone backends (single-user mode) will use local + * buffers and operate on temporary relations. Parallel workers will not + * use local buffers (see InitLocalBuffers()); however, extensions + * leveraging background workers have no such limitation, so track IO on + * IOOBJECT_TEMP_RELATION for BackendType B_BG_WORKER. */ no_temp_rel = bktype == B_AUTOVAC_LAUNCHER || bktype == B_BG_WRITER || bktype == B_CHECKPOINTER || bktype == B_AUTOVAC_WORKER || - bktype == B_STANDALONE_BACKEND || bktype == B_STARTUP; + bktype == B_STARTUP; if (no_temp_rel && io_context == IOCONTEXT_NORMAL && io_object == IOOBJECT_TEMP_RELATION) [parent: 2490a7564604]