On 11/12/2025 05:06, Ashutosh Bapat wrote:
On Thu, Dec 11, 2025 at 12:49 AM Heikki Linnakangas <[email protected]> wrote:

On 09/12/2025 14:00, Heikki Linnakangas wrote:
1. Currently, at multixid wraparound, MultiXactState->nextMXact goes to
0, which is invalid. All the readers must be prepared for that, and skip
over the 0. That's error-prone, we've already missed that a few times.
Let's change things so that the code that *writes* MultiXactState-
  >nextMXact skips over the zero already.

Here's a patch for that. Does anyone see a problem with this?

The patch looks fine to me. It simplifies readers without affecting
writers much. I was expecting more explanation of why it wasn't done
that way to start with and why is it safe to do so (now, if
applicable). There must be a reason why we chose to make readers
handle invalid mxid instead of writers writing one. If it's for
performance reasons then does the new arrangement cause any
regression? If it's for safety reasons, are we fixing one set of
problems but introducing a new set. I was expecting commit message to
answer those questions.

That's a great question and I've been wondering about it myself. It goes all the way to the initial commit where multixacts were introduced, and I don't see any particular reason for it even back then. Even in the very first version of multixact.c, IMO it would've been simpler to have the writer handle the wraparound.

Álvaro, would you happen to remember?

- Heikki



Reply via email to