Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDxHg-0004zk-5X for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Sep 2020 22:00:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDxHe-0004lj-Sg for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Sep 2020 22:00:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDxHe-0004lc-Lq for pgsql-hackers@lists.postgresql.org; Thu, 03 Sep 2020 22:00:42 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kDxHb-0003Mc-5s for pgsql-hackers@lists.postgresql.org; Thu, 03 Sep 2020 22:00:41 +0000 Received: by mail-qt1-x844.google.com with SMTP id e7so3148933qtj.11 for ; Thu, 03 Sep 2020 15:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=7yNKUsLw/c9gZN8w0tubxbgkr9Ilb8KMqviBFHD9YRo=; b=ZxMMgkobhMMbe9N6eZm+W5rtImqNCLlZK0lIXQSi8Q4GME4Vs2E2XV4W9C2RTYHu4j XR2UYGZjO1dsqK6q7p7A8uSnMnHRgVaJgaosja/P5uspuZyPiiuaekB3GZ76yMCsmMhn iLpqK+bhNybe7rTXVgQQV4C2yUdXccYCBj6J1mzO6s18EPrfhZ+DuTHiF5YB+qknaaTu JHKig1JwPbM2Bd0grxMQfEYVRqBHaEhqD37VFHjOWo9xhM7P0+DP0gxY/KLiMRObrDwM USY3SjVLeIjnpGnWyn0iu4jKIXRnQ51hGQZhoC00jLShAollfTVe4oV2wlC2jUDoIKQy aUMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=7yNKUsLw/c9gZN8w0tubxbgkr9Ilb8KMqviBFHD9YRo=; b=fNu9f1bSLCUyp7s8yRO4WGqEvwuf9SkqkvNCueEsZ49oaY6SyWm0PgEwPYJ+r1EKKm aV4vnlqLBGRDL9l4pnLtNyx7f/PL71Cpp3XcOveUJrcdzcmIuMdWyNbQQacEFC+Dp5va WV0smLES+V/huyTniBW52MktZa94fS4vI+jylcDKkBI2meytNKVAq3yG2iAAR4t2+5n6 yhFFWqH0WdRVxqtjrXzdAj1XXqG/ux7IhY/0YwK8uzB3rOC2VVvqKCucvVLjvMJSYlXc ZlhP8Y3/P1NmtYCViKWwXGzL4yvEowbzCbtPhFP5xqK5eFmP1OF6CAoO4rjWxm8TpU6H f7OA== X-Gm-Message-State: AOAM532y0IRDrqirYf8YssWWmXNesaEL4sY81DylXjlrKu2aD+A0zm7y tzo2ka50F0ieXE4kfleaLuF+GwdQLxV/WM8ctpg1J3VDw4b+7gEzEf9OhCrM7HDh66ZLLp0qqLK /V1RcTFiP/1xy2Mw7Sh7UggPg+9GLhIM/pC7IpoiJeKnU0BA0dYWBy2255VEawP8zuFoIj4GbQ4 4R1mMrhPWD3G3ubK0t X-Google-Smtp-Source: ABdhPJw8GOhO1lKJx1C8syeqVIbF0GO84sZcR00svad0ielcmY2jvK1olMlG5LLT7ftebUDcXWOU9g== X-Received: by 2002:aed:36aa:: with SMTP id f39mr5946113qtb.297.1599170436942; Thu, 03 Sep 2020 15:00:36 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id x6sm3176103qke.54.2020.09.03.15.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 15:00:36 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id F179A2A0FB5; Thu, 3 Sep 2020 18:00:34 -0400 (-04) Date: Thu, 3 Sep 2020 18:00:34 -0400 From: Alvaro Herrera To: Tom Lane Cc: Pg Hackers Subject: Re: report expected contrecord size Message-ID: <20200903220034.GA22006@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <792244.1599168691@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Sep-03, Tom Lane wrote: > Alvaro Herrera 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