Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgvrb-008iKQ-BU for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Mar 2024 00:07:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rgvrZ-002meO-2K for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Mar 2024 00:07:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgvrY-002meG-Qf for pgsql-bugs@lists.postgresql.org; Mon, 04 Mar 2024 00:07:25 +0000 Received: from mail-yw1-x112a.google.com ([2607:f8b0:4864:20::112a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rgvrW-002cw2-LM for pgsql-bugs@lists.postgresql.org; Mon, 04 Mar 2024 00:07:24 +0000 Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-608e0b87594so39973117b3.1 for ; Sun, 03 Mar 2024 16:07:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1709510841; x=1710115641; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=z5ZyI6bx8vVuTAaZfz1tRI9my/uofxCN8JPJOUjHVY8=; b=LOGF3+1y6ujWM6HvOnkmgYHjugdUy9wCUZuptFu6Xkf7tylDpfhKIO6cflMwQa56lN mB/BEfnffd2KFwcAP3k+Z2ypxEpz/lSFxqjdKE2MBPw/BVs1+CmVhShuV1nQ9oHAq6U/ axMM/Ozbm175RrlMUyZMm3gXwBy1T9hIdcTK8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709510841; x=1710115641; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=z5ZyI6bx8vVuTAaZfz1tRI9my/uofxCN8JPJOUjHVY8=; b=CIipI4yk9eTpmuFHxZAoT7ohYOEMdsq28snlWiwLcspkRmTVRfbU1RokDfGjaOD3M0 31r9TA3wherO5yVH0g0gvBgij5QsxdAcKs7xzpmYDGISKbBE+TzzJ+Nvm6cA9EgMtqfZ 4Yh/446tSz0rL+E0m2JVXk1ys5X6Iu9bkkYSD5P9Fly6eRxo6IvBwIWV10afC/Zj5Gjp ff0IYV2AUa3r7wKVfq0IKgVd72XeM0dAxYN1XXurnqL8k1CmvgPDvwkdZyrK0Ae4n226 3gQ/fuZQahw/MFvU55Jef0wecOHmqb96ANqhna/wJXoMq0MyOQroGhlVCbXY21WgllP6 mQVw== X-Forwarded-Encrypted: i=1; AJvYcCWIqHxS3umh3aABAeyJ7giqg0YrehNGZxYy/+l4CEHUetkPhedu6wP8FgHu5Tt7ZwqG2tkBZ/gQG+Sm4tawOnmEOxPtWHA4uzC0mwLKI28V X-Gm-Message-State: AOJu0Yz3PAP0yoQeH/3/XMCP/EJeHDTelQqPs9zStO729EqPxNAnCEsT dBAwPVAnBpJqOyTZ7ElXyQnAdEnX23+7VOVBJK8Y4uay3LdLfCyIyxv22CSCow== X-Google-Smtp-Source: AGHT+IG4xI59H7RmAmsavdRf2TvNppNHoOniFm4r/ADtkrZ2wBd8JUYJU/DjhL2CQfHkccmAhN6mEA== X-Received: by 2002:a81:a1c1:0:b0:609:8e9c:d3ca with SMTP id y184-20020a81a1c1000000b006098e9cd3camr4823226ywg.12.1709510841086; Sun, 03 Mar 2024 16:07:21 -0800 (PST) Received: from rfd.leadboat.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id s63-20020a0de942000000b006097887f574sm2068797ywe.80.2024.03.03.16.07.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2024 16:07:20 -0800 (PST) Date: Sun, 3 Mar 2024 16:07:17 -0800 From: Noah Misch To: robertmhaas@gmail.com, melanieplageman@gmail.com Cc: Peter Geoghegan , Matthias van de Meent , Alexander Lakhin , PostgreSQL mailing lists , Andres Freund Subject: relfrozenxid may disagree with row XIDs after 1ccc1e05ae Message-ID: <20240304000717.1e@rfd.leadboat.com> References: <17257-1e46de26bec11433@postgresql.org> <20231225024402.77@rfd.leadboat.com> <20240106202413.e5@rfd.leadboat.com> <20240106224448.c7@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240106224448.c7@rfd.leadboat.com> User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Jan 06, 2024 at 02:44:48PM -0800, Noah Misch wrote: > On Sat, Jan 06, 2024 at 01:30:40PM -0800, Peter Geoghegan wrote: > > On Sat, Jan 6, 2024 at 12:24 PM Noah Misch wrote: > > > Fair enough. While I agree there's a decent chance back-patching would be > > > okay, I think there's also a decent chance that 1ccc1e05ae creates the problem > > > Matthias theorized. Something like: we update relfrozenxid based on > > > OldestXmin, even though GlobalVisState caused us to retain a tuple older than > > > OldestXmin. Then relfrozenxid disagrees with table contents. I figure Matthias's upthread theory is more likely than not to hold. If it does hold, commit 1ccc1e05ae created a new corruption route. Hence, I'm adding a v17 open item for commit 1ccc1e05ae. > > Either every relevant code path has the same OldestXmin to work off > > of, or the whole NewRelfrozenXid/relfrozenxid-tracking thing can't be > > expected to work as designed. I find it a bit odd that > > pruneheap.c/GlobalVisState has no direct understanding of this > > dependency (none that I can discern, at least). Wouldn't it at least > > be more natural if pruneheap.c could access OldestXmin when run inside > > VACUUM? (Could just be used by defensive hardening code.) > > Tied to that decision is the choice of semantics when the xmin horizon moves > backward during one VACUUM, e.g. when a new walsender xmin does so. Options: > > 1. Continue to remove tuples based on the OldestXmin from VACUUM's start. We > could have already removed some of those tuples, so the walsender xmin > won't achieve a guarantee anyway. (VACUUM would want ratchet-like behavior > in GlobalVisState, possibly by sharing OldestXmin with pruneheap like you > say.) > > 2. Move OldestXmin backward, to reflect the latest xmin horizon. (Perhaps > VACUUM would just pass GlobalVisState to a function that returns the > compatible OldestXmin.) > > Which way is better?