From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: report expected contrecord size
Date: Thu, 3 Sep 2020 18:00:34 -0400
Message-ID: <20200903220034.GA22006@alvherre.pgsql> (raw)
In-Reply-To: <792244.1599168691@sss.pgh.pa.us>
On 2020-Sep-03, Tom Lane wrote:
> Alvaro Herrera <alvherre@2ndquadrant.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, tgl@sss.pgh.pa.us
Subject: Re: report expected contrecord size
In-Reply-To: <20200903220034.GA22006@alvherre.pgsql>
References: <792244.1599168691@sss.pgh.pa.us> <20200903220034.GA22006@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox