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 1kDxnC-0006Qx-65 for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Sep 2020 22:33:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDxnA-000541-LN for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Sep 2020 22:33:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDxnA-00053u-AA for pgsql-hackers@lists.postgresql.org; Thu, 03 Sep 2020 22:33:16 +0000 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kDxn5-0004Kk-54 for pgsql-hackers@lists.postgresql.org; Thu, 03 Sep 2020 22:33:15 +0000 Received: by mail-qt1-x834.google.com with SMTP id n18so3285018qtw.0 for ; Thu, 03 Sep 2020 15:33:10 -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=qUnDIyIRK2lyLBopbZyKHvQI/n+opDxnr26REczdcJw=; b=eF3Eb7zW8klhA6tumcBlWYJUq3+97fRhPn2qz6Hxaub/RFSmENXdmwN/bcynUWa2kI lYZX0y7wdNLC/tCPbOksbEkUSLygmrxPiMeQ79X/F7wdql+/RJ5G0J3k5AwLr1T7uEv3 /vBfM1w+k8hIg4J2+6RK7MxDnMAWBGylX3MzxRLbzFVtd1FQLXn1APKA5kMaZlW3lHHD vWJrqNdl1hiaf5FbTeAjJN8/XPF9fVpq8psr6sRWGtdLOOn0TuVwkdU6NsxJkNUnrxpR rNCxSz1gtJAiMZpcjvIa5PMEprdqf4CCmaylW9r4wglJdvEz/bMWmmOOcQAGTHz6uI7U BhuQ== 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=qUnDIyIRK2lyLBopbZyKHvQI/n+opDxnr26REczdcJw=; b=q+k8tmNWQRfEG1xnIpBWfop9SlRDghdIhQxdR5rP0sDzvGRWm9DrY9AtK61S23MefH 64NCGKCSTX10RJCeb8ts02lkd2Rxe6HzVunj7PV+xjbl3G/iWeMkHMRasnhpUFUQjjoa AhXxSxX6Dnjm0aMr8xmHuvkuHmRj5L1n/SVyNujSq1BDAGM7dSqzsFWqTMt+bmE/OWhD RJCMi4FEaoX8DiHf6SiWJPst1mdnQA3ddMFS/fo70WOYY22LgWd6eloSnBnAaVe5YVwO gqAIeLl909MW46ZC/fTM5xg2eT9B1sm9pUvGaOleqZW/g8qc7juuOKIrKCToisQ2ZPfV chJQ== X-Gm-Message-State: AOAM532SZzfhk4uq2LEU9UYi8/qoX/3n5/C44GU4XOd81r/N10cijYnL tnB2DmrneSoshHQnFebiugNx6xhPts7CZCDVhM6IiA7X4x68R2OfW2s0wCDvrPLsEh2FXjyEha4 Cakl5bgZ6bNpD1Gy6AjMfDBzsGUTN0EZ8TfEY5Lbfn8izHsjyXqlpyDHV5UTu9C6S65fO+EoCZp AlrT3l77La4gXmcfRW X-Google-Smtp-Source: ABdhPJx37TddvYAlIwD7g45QZ0tMq16AadMgqAoR+xpP26W0hXZ9J5dMkpxg7fSkreU/TSo4UKPvQA== X-Received: by 2002:aed:2ce7:: with SMTP id g94mr5938465qtd.184.1599172390119; Thu, 03 Sep 2020 15:33:10 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id i66sm3319131qkc.63.2020.09.03.15.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 15:33:09 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 0B7EF2A0FB5; Thu, 3 Sep 2020 18:33:08 -0400 (-04) Date: Thu, 3 Sep 2020 18:33:08 -0400 From: Alvaro Herrera To: Tom Lane Cc: Pg Hackers Subject: Re: report expected contrecord size Message-ID: <20200903223308.GA25785@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <795510.1599171450@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: > > 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. > > Uh ... is it really possible for gotlen to be more than total_len? > (I've not looked at the surrounding code here, but that seems weird.) Well, as I understand, total_len comes from one page, and gotlen comes from the continuation record(s) in the next page(s) of WAL. So if things are messed up, it could happen. (This *is* the code that validates the record, so it can't make too many assumptions.) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services