| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: xid_wraparound: Fix XID consumption accounting |
| Date: | 2026-11-18 05:00:30 |
| Message-ID: | E1xTXmX-00000000Bwg-0E7X@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
xid_wraparound: Fix XID consumption accounting
When the current transaction had not yet been assigned a top-level
XID, consume_xids(n) consumed n + 1 XIDs because the initial top-level
XID allocation was not included in the count. Include that allocation
so that the function consumes exactly n XIDs.
In particular, consume_xids(1) now consumes and returns only the
top-level XID in this case, rather than consuming two XIDs and
returning the second. consume_xids(0) now raises an error instead of
returning the next unallocated XID.
With 32kB blocks, bulk XID consumption could also consume more XIDs
than requested or return an outdated XID. Restrict this optimization
so that consume_xids(n) always consumes exactly n XIDs and returns
the last XID it assigned.
Backpatch to 17, where the xid_wraparound test module was introduced.
Author: Yushi Ogiwara <btogiwarayuushi(at)oss(dot)nttdata(dot)com>
Author: João Rito <joaovictor(dot)rito(at)gmail(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/2a62f138c9dcb6fcf5889b076d123aa2@oss.nttdata.com
Backpatch-through: 17
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/344322da515e7eed56300f52f95ef320753c12d1
Modified Files
--------------
src/test/modules/xid_wraparound/xid_wraparound.c | 52 ++++++++++++++++--------
1 file changed, 36 insertions(+), 16 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2026-11-18 05:19:44 | pgsql: Doc: Explain prepared transaction lock waits with two_phase subs |
| Previous Message | Fujii Masao | 2026-11-18 05:00:06 | pgsql: xid_wraparound: Fix XID consumption accounting |