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 1k1F0F-0006t4-CP for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Jul 2020 20:18:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k1F0E-0003GY-BN for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Jul 2020 20:18:10 +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 1k1F0D-0003GQ-Vs for pgsql-hackers@lists.postgresql.org; Thu, 30 Jul 2020 20:18:10 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k1F0A-00070b-DQ for pgsql-hackers@postgresql.org; Thu, 30 Jul 2020 20:18:09 +0000 Received: by mail-pl1-x644.google.com with SMTP id g19so2622567plq.0 for ; Thu, 30 Jul 2020 13:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ga9JkyB2I5vbYdMDkPfT08PziRem8R0sv2V0gAEw7Jg=; b=BzLrXvU5XJSkih6T4sfQdtGI4OUdxEEophqX/5S4b3/q5On4/0/5xlnsbtVdqhZlJf 9Qq87r76JvAj82lE92O4WvE0cKikLB5Ft0RHPSh66fGJS3Zid7wDp+HhuR2tXjEE9tBh B0sl5sokuZwNtE0i0SIqcyNZux/0TwTW3BkFct9gAnhuhweJNT9yhQpny0JNE8H2I6QC g09cCDkjjYmZzJ5FEW8gfueEU8ZgfzluqnWFM8oRXE8Vc79gSiATI+7wnh1fWvkdoFIp jMYTYRj3WHQw+GWx2pSx3gdX02ZXRgyLRJhs3YrvpfD5ancHHZzgNaKjEhYgVWOqNU3/ lxQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ga9JkyB2I5vbYdMDkPfT08PziRem8R0sv2V0gAEw7Jg=; b=fwGkbIzXWe0kY60i8RPJHIQ8aaog9ggr+mAwVPb8SRSk+hMEKPbMHKzDZpkCiNI5uK ccrna0ilV9IeenUzPB5dONFwE/aAEm7pJsyahmfs24gYQwf6/nPyBWtWRb8Xty/1oC94 zh6i1X9a9+6KYBOC9R17h7/Kb0NZ//jwp09tib8ZKTYaqXBCQ5ihOwlkPVB8VeImtvJg j3yhV4LczIfbASFNBCHyIM21ed+oCZRezNrWMllxGx6Y132Zv2owqCNETrcZlX4ST3eG 7hTpT7ZcazKDn9jh3KjoZJF/XHjhwKYT8jqUoTfBynN4ly4LffMNj/SCNHlVGYMCij4b Xnug== X-Gm-Message-State: AOAM5333vMApiQ17NAU6aLaedLyToDIz2fRA38bgPm++CGktvYdb1GFH /JcyGE4KjPe2ush6Qc1/G3ma+BcPt+bwqa+ivK9ELU1lJUTzx7f2+/P3C66mlA7XeZ5VGrR9Y12 Bk0UoGxSDab8o2/fARMihrr1tIYa7sBVpprLu0JaNXyjwbMPhHGusAoDH9jlb095ndlI5r08TmD bD09f3GdzKyOU3+NTclTDrr+ZxQDZDgMwVZLFw X-Google-Smtp-Source: ABdhPJwTQsCY1RplzE/EYzHoUcQ4ltoLLJrznxM795j9smvxIxq1F5cUJ3va9rtgC4Bnc8sCG+244w== X-Received: by 2002:a17:90a:f83:: with SMTP id 3mr741591pjz.7.1596140283870; Thu, 30 Jul 2020 13:18:03 -0700 (PDT) Received: from [192.168.0.29] (24-113-193-150.wavecable.com. [24.113.193.150]) by smtp.gmail.com with ESMTPSA id g18sm7176305pfi.141.2020.07.30.13.18.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jul 2020 13:18:03 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: new heapcheck contrib module From: Mark Dilger In-Reply-To: Date: Thu, 30 Jul 2020 13:18:01 -0700 Cc: Dilip Kumar , Peter Geoghegan , Andres Freund , PostgreSQL-development Content-Transfer-Encoding: quoted-printable Message-Id: References: <12ED3DA8-25F0-4B68-937D-D907CFBF08E7@enterprisedb.com> <20200420194210.sevnpi4lyghoanxi@alap3.anarazel.de> <23E60C3C-C20A-4508-84AC-E0CEA59E784A@enterprisedb.com> <5F743835-3399-419C-8324-2D424237E999@enterprisedb.com> <885D2EC9-7D06-4903-A17D-72C184A1E1C5@enterprisedb.com> <5CC85F28-F210-47AC-8DA8-EC4E82AF3FD5@enterprisedb.com> <0C0349EB-DD85-4DA8-82C7-DF70AB714592@enterprisedb.com> To: Robert Haas X-Mailer: Apple Mail (2.3608.80.23.2.2) X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Jul 29, 2020, at 12:52 PM, Robert Haas = wrote: >=20 > On Mon, Jul 20, 2020 at 5:02 PM Mark Dilger > wrote: >> I've made the options 'all-visible', 'all-frozen', and 'none'. It = defaults to 'none'. >=20 > That looks nice. >=20 >>> I guess that >>> could still be expensive if there's a lot of them, but needing >>> ShareUpdateExclusiveLock rather than only AccessShareLock is a = little >>> unfortunate. >>=20 >> I welcome strategies that would allow for taking a lesser lock. >=20 > I guess I'm not seeing why you need any particular strategy here. Say > that at the beginning you note the starting relfrozenxid of the table > -- I think I would lean toward just ignoring datfrozenxid and the > cluster-wide value completely. You also note the current value of the > transaction ID counter. Those are the two ends of the acceptable > range. >=20 > Let's first consider the oldest acceptable XID, bounded by > relfrozenxid. If you see a value that is older than the relfrozenxid > value that you noted at the start, it is definitely invalid. If you > see a newer value, it could still be older than the table's current > relfrozenxid, but that doesn't seem very worrisome. If the user > vacuumed the table while they were running this tool, they can always > run the tool again afterward if they wish. Forcing the vacuum to wait > by taking ShareUpdateExclusiveLock doesn't actually solve anything > anyway: you STILL won't notice any problems the vacuum introduces, and > in fact you are now GUARANTEED not to notice them, plus now the vacuum > happens later. >=20 > Now let's consider the newest acceptable XID, bounded by the value of > the transaction ID counter. Any time you see a newer XID than the last > value of the transaction ID counter that you observed, you go observe > it again. If the value from the table still looks invalid, then you > complain about it. Either way, you remember the new observation and > check future tuples against that value. I think the patch is already > doing this anyway; if it weren't, you'd need an even stronger lock, > one sufficient to prevent any insert/update/delete activity on the > table altogether. >=20 > Maybe I'm just being dense here -- exactly what problem are you = worried about? Per tuple, tuple_is_visible() potentially checks whether the xmin or = xmax committed via TransactionIdDidCommit. I am worried about = concurrent truncation of clog entries causing I/O errors on SLRU lookup = when performing that check. The three strategies I had for dealing with = that were taking the XactTruncationLock (formerly known as = CLogTruncationLock, for those reading this thread from the beginning), = locking out vacuum, and the idea upthread from Andres about setting = PROC_IN_VACUUM and such. Maybe I'm being dense and don't need to worry = about this. But I haven't convinced myself of that, yet. =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company