Re: report expected contrecord size

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: report expected contrecord size
Date: 2020-09-03 22:00:34
Message-ID: 20200903220034.GA22006@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2020-Sep-03, Tom Lane wrote:

> Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> > A pretty minor issue: when reporting that WAL appears invalid because
> > contrecord length doesn't match, we may as well print to the server log
> > the value that we're expecting. Patch attached.
>
> ITYW
>
> + (long long) (total_len - gotlen),
>
> just to be sure about what's getting casted to what.

Well, the intention there is to cast the first operand (which is uint32)
so that it turns into signed 64-bits; the subtraction then occurs in 64
bit arithmetic normally. If I let the subtraction occur in 32-bit width
unsigned, the result might overflow 32 bits. I'm thinking in
1 - UINT32_MAX or some such.

Maybe to make that more explicit, it should be

+ ((long long) total_len) - gotlen,

(If I understand the precedence correctly, it's the same thing I wrote).

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-09-03 22:17:30 Re: report expected contrecord size
Previous Message Bossart, Nathan 2020-09-03 21:39:55 Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions