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 1rNePk-00EEsK-UH for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Jan 2024 19:39:01 +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 1rNePk-0076l0-1T for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Jan 2024 19:39:00 +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 1rNePj-0076kb-IT for pgsql-bugs@lists.postgresql.org; Wed, 10 Jan 2024 19:38:59 +0000 Received: from mail-yw1-x112d.google.com ([2607:f8b0:4864:20::112d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rNePg-000sth-Rz for pgsql-bugs@lists.postgresql.org; Wed, 10 Jan 2024 19:38:58 +0000 Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-5f15a1052b3so41286367b3.1 for ; Wed, 10 Jan 2024 11:38:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1704915535; x=1705520335; 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=f5BpzxsGUvfSx9T2ySQ3qFooGuD+LuVcnqapGsiOsRQ=; b=UoCUFUWtO7iv7z8DLQe+wJu1FMF/gdm6+JASTgb+/nlz45lLKybQz8dYEIncNMvjhA 5cJKGYswGL/Y3TBw7i/2SbFVO3f4Bq+sjlp/iWhhCSvFKTPtW0oerGDQndnYk9EXtOt9 uoI1Z6QcihP4QBwXb64iKvQFnwxOehZj0iDLs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704915535; x=1705520335; 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=f5BpzxsGUvfSx9T2ySQ3qFooGuD+LuVcnqapGsiOsRQ=; b=Ef2ZwMjUQoqayNW147KGgG869Q+pwZtuwU7RfEfVcQQF2RyvKNTROoI/4SMSd7VCf+ rGPLVUjMKoBcYI0LSM/rgfB/0ZLDScgfIfA7+RrG1MuTiVk8f0Bmqfo7SX+OOApyRQjX I68nXzkeeENZD/s6NK4Xzdsn6EmOF0A/LI56IZCZ4HrC14vPbgsQShsU5an9k0K+Mx1y 2NRhkpqws40JZobMVV5fNAuQZ/seHvBS8lwIvrJm9gnpkibBs7TEBhOaDw2xxulPvTHn UZOfaRS3V72JtWN4BobWxc2EtEpojpdqEGiKZEURd8deD17NRW8EfWEvMMLPZ8YPyiQB 6GzA== X-Gm-Message-State: AOJu0Yx2CEjIqnCKpz3EGL62H4TXLGoXjzyK/xvERWe5NPVpvU25YDxg h/jQnuB5OaIVTY4zQaAh9+gPGDLYTPju8H9s9U7euRZzWA== X-Google-Smtp-Source: AGHT+IGklW2J7YpwGqOGV2s/CHs58e9S5DCKq1O+gV5E7mR0nP2VczJ4VI4QWKedmHt9aes+/Obq/Q== X-Received: by 2002:a81:e44a:0:b0:5f2:e3f5:dc8d with SMTP id t10-20020a81e44a000000b005f2e3f5dc8dmr154382ywl.40.1704915535019; Wed, 10 Jan 2024 11:38:55 -0800 (PST) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id l184-20020a8194c1000000b005ecd8995666sm1822616ywg.59.2024.01.10.11.38.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2024 11:38:54 -0800 (PST) Date: Wed, 10 Jan 2024 11:38:51 -0800 From: Noah Misch To: Peter Geoghegan Cc: Matthias van de Meent , robertmhaas@gmail.com, Alexander Lakhin , PostgreSQL mailing lists , Andres Freund Subject: Re: BUG #17257: (auto)vacuum hangs within lazy_scan_prune() Message-ID: <20240110193851.f0.nmisch@google.com> References: <17257-1e46de26bec11433@postgresql.org> <20231225024402.77@rfd.leadboat.com> <20240106202413.e5@rfd.leadboat.com> <20240109214447.88@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 Wed, Jan 10, 2024 at 02:06:42PM -0500, Peter Geoghegan wrote: > On Tue, Jan 9, 2024 at 6:16 PM Peter Geoghegan wrote: > > On Tue, Jan 9, 2024 at 4:44 PM Noah Misch wrote: > > > On Tue, Jan 09, 2024 at 03:59:19PM -0500, Peter Geoghegan wrote: > > > > Did the affected system that you investigated happen to have an > > > > atypically high number of databases? The system 15.4 system that I saw > > > > the problem on had almost 3,000 databases. > > > > > > No, single-digit database count here. > > > > My suspicion was that this factor might increase the propensity of > > calls to GetOldestNonRemovableTransactionId (used to establish > > VACUUM's OldestXmin) to not agree with the GlobalVis* based state used > > by pruneheap.c, in the way that we need to worry about here (i.e. > > inconsistencies that lead to VACUUM getting stuck inside > > lazy_scan_prune's loop). > > Another question about your database/system: does VACUUM get stuck > while scanning a page some time after it has already completed a round > of index vacuuming? I don't know. That particular system experienced the infinite loop only once. > That's what I see here -- I don't think that pruning leaves behind > even a single live heap tuple, despite scanning thousands of pages > before reaching the page that it gets stuck on. Could be another red > herring. But it doesn't seem impossible that some of the nbtree calls > to procarray.c routines performed by code added by my commit > 9dd963ae25, "Recycle nbtree pages deleted during same VACUUM", are > somehow related. That is, that code could be part of the chain of > events that cause the problem (whether or not the code itself is > technically at fault). > > I'm referring to calls such as the > "GetOldestNonRemovableTransactionId(NULL)" and > "GlobalVisCheckRemovableFullXid()" calls that take place inside > _bt_pendingfsm_finalize(). It's not like we do stuff like that in very > many other places. I see what you mean about the rarity and potential importance of "GetOldestNonRemovableTransactionId(NULL)". There's just one other caller, vac_update_datfrozenxid(), which calls it for an unrelated cause.