Re: POC: make mxidoff 64 bits

Heikki Linnakangas <hlinnaka@iki.fi>

From: Heikki Linnakangas <hlinnaka@iki.fi>
To: zengman <zengman@halodbtech.com>
Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-01-04T18:06:06Z
Lists: pgsql-hackers
On 30/12/2025 03:49, zengman wrote:
> Hi,
> 
> I'm currently looking into the `SlruReadSwitchPageSlow` function and have a question regarding the expression `&state->buf.data + bytes_read` —
> I suspect the ampersand (&) here might be misused. Would you be able to help me verify this?
> 
> ```
> 	while (bytes_read < BLCKSZ)
> 	{
> 		ssize_t		rc;
> 
> 		rc = pg_pread(state->fd,
> 					  &state->buf.data + bytes_read,
> 					  BLCKSZ - bytes_read,
> 					  offset);
> 		if (rc < 0)
> 		{
> 			if (errno == EINTR)
> 				continue;
> 			pg_fatal("could not read file \"%s\": %m", state->fn);
> 		}
> 		if (rc == 0)
> 		{
> 			/* unexpected EOF */
> 			pg_log(PG_WARNING, "unexpected EOF reading file \"%s\" at offset %u, reading as zeros",
> 				   state->fn, (unsigned int) offset);
> 			memset(&state->buf.data + bytes_read, 0, BLCKSZ - bytes_read);
> 			break;
> 		}
> 		bytes_read += rc;
> 		offset += rc;
> 	}
> ```
> 
> ```
> 		rc = pg_pread(state->fd,
> 					  &state->buf.data + bytes_read,
> 					  BLCKSZ - bytes_read,
> 					  offset);
> memset(&state->buf.data + bytes_read, 0, BLCKSZ - bytes_read);
> ```

Yes, you're right. Good catch! Committed the fix, thanks.

- Heikki




Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix partial read handling in pg_upgrade's multixact conversion

  2. Increase timeout in multixid_conversion upgrade test

  3. Improve sanity checks on multixid members length

  4. Clarify comment on multixid offset wraparound check

  5. Never store 0 as the nextMXact

  6. Add runtime checks for bogus multixact offsets

  7. Widen MultiXactOffset to 64 bits

  8. Move pg_multixact SLRU page format definitions to a separate header

  9. Convert confusing macros in multixact.c to static inline functions

  10. Index SLRUs by 64-bit integers rather than by 32-bit integers

  11. Cope with possible failure of the oldest MultiXact to exist.