Re: IPC/MultixactCreation on the Standby server
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Chao Li <li.evan.chao@gmail.com>
Cc: Álvaro Herrera <alvherre@kurilemu.de>, pgsql-hackers@lists.postgresql.org, Andrey Borodin <x4mmm@yandex-team.ru>, Ivan Bykov <i.bykov@modernsys.ru>, Kirill Reshke <reshkekirill@gmail.com>
Date: 2025-11-27T07:24:51Z
Lists: pgsql-hackers
On 27/11/2025 05:39, Chao Li wrote:
>> <v11-0001-Avoid-multixact-edge-case-2-by-writing-the-next-.patch>
>
> 1
> ```
> + if (*offptr != offset)
> + {
> + /* should already be set to the correct value, or not at all */
> + Assert(*offptr == 0);
> + *offptr = offset;
> + MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
> + }
> ```
>
> This is a more like a question. Since pre-write should always happen, in theory *offptr != offset should never be true, why do we still need to handle the case instead of just assert(false)?
No, *offptr == 0 can happen, if multiple backends are generating
multixids concurrently. It's possible that we get here before the
RecordNewMultiXact() call for the previous multixid.
Similarly, the *next_offptr != 0 case can happen if another backend
calls RecordNewMultiXact() concurrently for the next multixid.
> 2
> ```
> + next = multi + 1;
> + if (next < FirstMultiXactId)
> + next = FirstMultiXactId;
> ```
>
> next < FirstMultiXactId will only be true when next wraps around to 0, maybe deserve one-line comment to explain that.
This is a common pattern used in many places in the file.
> 3
> ```
> + if (*next_offptr != offset + nmembers)
> + {
> + /* should already be set to the correct value, or not at all */
> + Assert(*next_offptr == 0);
> + *next_offptr = offset + nmembers;
> + MultiXactMemberCtl->shared->page_dirty[slotno] = true;
> + }
> ```
>
> Should MultiXactMemberCtl be MultiXactOffsetCtl? As we are writing to the offset SLRU.
Good catch! Yes, it should be MultiXactOffsetCtl.
- Heikki
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix test to work with non-8kB block sizes
- 7c2061bdfba7 19 (unreleased) landed
-
Fix setting next multixid's offset at offset wraparound
- 48969555447f 14.21 landed
- b9a02b9780bc 15.16 landed
- 4d689a17693e 16.12 landed
- cad40cec24f3 17.8 landed
- 02ba5e3be4f3 18.2 landed
- 4d936c3fff1a 19 (unreleased) landed
-
Add test for multixid wraparound
- 7b81be9b4267 19 (unreleased) landed
-
Set next multixid's offset when creating a new multixid
- 81416e1016dd 14.21 landed
- 8cfb174a61eb 15.16 landed
- 635166913078 16.12 landed
- 8ba61bc06386 17.8 landed
- e46041fd973c 18.2 landed
- 789d65364cde 19 (unreleased) landed
-
psql: Improve tab completion for large objects.
- 14ee8e640300 19 (unreleased) cited
-
Refactor some repetitive SLRU code
- c61678551699 19 (unreleased) cited
-
Transaction IDs wrap around, per my proposal of 13-Aug-01. More
- bc7d37a525c0 7.2.1 cited