pgsql: Fix newly introduced bug in slab.c

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix newly introduced bug in slab.c
Date: 2022-12-21 20:58:46
Message-ID: E1p86An-004luw-EF@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix newly introduced bug in slab.c

d21ded75f changed the way slab.c works but introduced a bug that meant we
could end up with the slab's curBlocklistIndex pointing to the wrong list.
The condition which was checking for this was failing to account for two
things:

1. The curBlocklistIndex could be 0 as we've currently got no non-full
blocks to put chunks on. In this case, the dlist_is_empty() check cannot
be performed as there can be any number of completely full blocks at that
index.

2. The curBlocklistIndex may be greater than the index we just moved the
block onto. Since we need to ensure we fill up fuller blocks first, we
must reset curBlocklistIndex when changing any blocklist element that's
less than the curBlocklistIndex too.

Reported-by: Takamichi Osumi
Discussion: https://postgr.es/m/TYCPR01MB8373329C6329768D7E093D68EDEB9@TYCPR01MB8373.jpnprd01.prod.outlook.com

Branch
------
master

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

Modified Files
--------------
src/backend/utils/mmgr/slab.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2022-12-21 22:00:32 pgsql: Introduce float4in_internal
Previous Message Peter Smith 2022-12-21 09:04:39 Re: pgsql: Doc: Explain about Column List feature.