Assertion failure with temporary relations in single-user mode

Поиск
Список
Период
Сортировка
Искать

Assertion failure with temporary relations in single-user mode

От:
Manu <manuelreyesbravo@gmail.com>
Дата:
Вложения:
Hi,

With assertions enabled, single-user mode fails an assertion as soon
as a temporary relation is read or written through local buffers,
from v16 to master:

$ echo "CREATE TEMP TABLE t AS SELECT 1;" | postgres --single postgres
TRAP: failed Assert("pgstat_tracks_io_op(MyBackendType, ...)")

28e626bde00 put B_STANDALONE_BACKEND in no_temp_rel, in
pgstat_tracks_io_object(), but a single-user backend uses local
buffers like a client backend.  Without assertions, that IO is not
counted: pg_stat_io has no "temp relation" row for it.

Patch with a test attached; the test also fails without assertions.
The back branches need small adjustments; tested on 16 to 19.

Regards,
Manu

Re: Assertion failure with temporary relations in single-user mode

От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Tue, Nov 17, 2026 at 9:32 AM Manu  wrote:
> Patch with a test attached; the test also fails without assertions.

Thanks for the report and patch!
The fix in pgstat_io.c seems good to me.

I wonder if adding a new TAP test file might be overkill for this fix.
Several similar fixes for assertion failures in single-user mode have
not included tests.

Using temporary tables in single-user mode seems uncommon,
so I'm not sure a dedicated test provides enough value to justify
the additional test runtime.

Regards,


-- 
Fujii Masao


Re: Assertion failure with temporary relations in single-user mode

От:
Manu <manuelreyesbravo@gmail.com>
Дата:
Вложения:
Hi Fujii,

On Tue, Nov 17, 2026 at 1:41 PM Fujii Masao
 wrote:
> I wonder if adding a new TAP test file might be overkill for this fix.

Agreed.  v2, attached, drops it and keeps only the fix in pgstat_io.c,
plus the new row in the stats regression test's list of pg_stat_io
rows.

The code change is the same down to 16.  The stats.out hunk differs
on 18 and 19, and 16 and 17 have no such list; I can post those
versions if they help.

Regards,
Manu

Re: Assertion failure with temporary relations in single-user mode

От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Tue, Nov 17, 2026 at 2:10 PM Manu  wrote:
> The code change is the same down to 16.  The stats.out hunk differs
> on 18 and 19, and 16 and 17 have no such list; I can post those
> versions if they help.

Yes, it's helpful if you provide the patches for those versions. Thanks!

Regards,

-- 
Fujii Masao


Re: Assertion failure with temporary relations in single-user mode

От:
Manu <manuelreyesbravo@gmail.com>
Дата:
Вложения:
Hi Fujii,

On Tue, Nov 17, 2026 at 4:15 PM Fujii Masao
 wrote:
> Yes, it's helpful if you provide the patches for those versions.
> Thanks!

Attached for 16, 17, 18 and 19.  The change to pgstat_io.c is the
same in all four; 18 and 19 also add the row to stats.out, and 16
and 17 have no such list.  Each applies with git am on its branch as
of today and passes check-world with assertions enabled.  For master,
v2 upthread is unchanged.

Regards,
Manu

Re: Assertion failure with temporary relations in single-user mode

От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Wed, Nov 18, 2026 at 6:41 AM Manu  wrote:
> Attached for 16, 17, 18 and 19.

Thanks for the patches! I've pushed them.

Regards,

-- 
Fujii Masao


Re: Assertion failure with temporary relations in single-user mode

От:
Manu <manuelreyesbravo@gmail.com>
Дата:
Hi Fujii,

On Wed, Nov 18, 2026 at 4:13 PM Fujii Masao  wrote:
> Thanks for the patches! I've pushed them.

Thanks for the review and for pushing it to all branches.

Regards,
Manu


Re: Assertion failure with temporary relations in single-user mode

От:
Michael Paquier <michael@paquier.xyz>
Дата:
Вложения:
On Tue, Nov 17, 2026 at 01:41:36PM +0900, Fujii Masao wrote:
> I wonder if adding a new TAP test file might be overkill for this fix.
> Several similar fixes for assertion failures in single-user mode have
> not included tests.

A TAP test would have felt like a waste of cycles to me, so I think
that what you have done in terms of 5c06a7ef24c7 under stats.out is
enough.
--
Michael
FAQ