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 1nUF2G-0001U1-S9 for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Mar 2022 21:48:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nUF2F-0006DV-N6 for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Mar 2022 21:48:55 +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 1nUF2F-0006D2-AY for pgsql-hackers@lists.postgresql.org; Tue, 15 Mar 2022 21:48:55 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nUF2D-0001eH-2F for pgsql-hackers@lists.postgresql.org; Tue, 15 Mar 2022 21:48:54 +0000 Received: by mail-ej1-x62d.google.com with SMTP id p15so405724ejc.7 for ; Tue, 15 Mar 2022 14:48:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gf6wf+oBmzJ7mK9DfYe+JTI+22QXmh0CSVS77nTAFu0=; b=fgYveiZNpVoyN2JIMKoTHMm5gEaNMPLPAJyDfSTQidcl/dMDgGekHUZ3w/xS8R8gN+ QWdZkxU1in0KOkLFZ9cW7BkzU5cAdrp/+WAc3aPSCJdBku+GuKYZdyvncIN0FTlm3MSN usnqkHuheUAQPWuOFGKgpRPRQu2ypX1Ai52mWcURUoDRX01ixlLOgtWFdOuCBq6UzcaL U/JUXwtzfXesxa5sWqPZESvEvf4JWnntQ5UAOYk3X+hUeSfn7xr+fAy1COdhb4l7mTAt NUYXsGZ4QpAF0KXvr+O9sJYsECp5xTKbj6e4Db0O36slsOW1UYYlIeEdR9yYF6QWtDa5 p81w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gf6wf+oBmzJ7mK9DfYe+JTI+22QXmh0CSVS77nTAFu0=; b=pbcxfipiLUi2f+0BcDCNuTp/ZO+KxrIMqvdjiH8v1VlNfFv09MJv1r4TtzJdGLdjiZ M6myslUe6f5mTFHEMZu6kzNX6HeXQeIAZ4YI/akzaFvk2gRFjQiC2ahnev8flDwUn/t3 GLoL6HLzqHZuyKM2GqZJ7a40lFjymZI0PJnz42PG0jM7sM9+SabDq1OuK2OxcGeAplGB 2mkCd0l4mi2y2a+Ltjd9NBdjEHiaGwsle2h4OnsBR91wNAWs57U8Dcuc2Z7MulHsPZkJ voCuiEJ0zYtQKBGsVtZxfzb96zZIOXnoWAb8Wm5Re64gg66/HlqpjPTp2K+IGD5ACina 7qCA== X-Gm-Message-State: AOAM532wqUW2orZ2Q1VqqivSTmrMz3LouMOYH9cOKYumlIYmadIijqKY aoZveWv7Qp4FpqOb6NIVgJJ60liqIWreaQfkyC6lcw== X-Google-Smtp-Source: ABdhPJzBmN1TqY1Gne0wgQwqP/pBMqEth8RyAovYGgvybmrAvJqgbR8D2O7bZ8uDWj09j4ez0Ok5tq/OJJHxcNs4/4Q= X-Received: by 2002:a17:907:1b09:b0:6d8:faa8:4a06 with SMTP id mp9-20020a1709071b0900b006d8faa84a06mr24287353ejc.701.1647380931688; Tue, 15 Mar 2022 14:48:51 -0700 (PDT) MIME-Version: 1.0 References: <20211210015616.o242b4xchhpglfcy@alap3.anarazel.de> <20220203215048.rmwjzixdzaetedxq@alap3.anarazel.de> In-Reply-To: From: Peter Geoghegan Date: Tue, 15 Mar 2022 14:48:24 -0700 Message-ID: Subject: Re: do only critical work during single-user vacuum? To: John Naylor Cc: Andres Freund , Robert Haas , PostgreSQL Hackers Content-Type: multipart/mixed; boundary="0000000000003e96cd05da48c313" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000003e96cd05da48c313 Content-Type: text/plain; charset="UTF-8" On Wed, Feb 16, 2022 at 12:43 AM John Naylor wrote: > I'll put some effort in finding any way that it might not be robust. > After that, changing the message and docs is trivial. It would be great to be able to totally drop the idea of using single-user mode before Postgres 15 feature freeze. How's that going? I suggest that we apply the following patch as part of that work. It adds one last final failsafe check at the point that VACUUM makes a final decision on rel truncation. It seems unlikely that the patch will ever make the crucial difference in a wraparound scenario -- in practice it's very likely that we'd have triggered the wraparound at that point if we run into trouble with the target rel's relfrozenxid age. And even if it does get to that point, it would still be possible for the autovacuum launcher to launch another autovacuum -- this time around we will avoid rel truncation, restoring the system to normal operation (i.e. no more xidStopLimit state). On the other hand it's possible that lazy_cleanup_all_indexes() will take a very long time to run, and it runs after the current final failsafe check. An index AM's amvacuumcleanup() routine can take a long time to run sometimes, especially with GIN indexes. And so it's just about possible that we won't have triggered the failsafe by the time lazy_cleanup_all_indexes() is called, which then spends a long time doing index cleanup -- long enough for the system to reach xidStopLimit due to the target rel's relfrozenxid age crossing the crucial xidStopLimit crossover point. This patch makes this problem scenario virtually impossible. Right now I'm only prepared to say it's very unlikely. I don't see a reason to take any chances, though. -- Peter Geoghegan --0000000000003e96cd05da48c313 Content-Type: application/octet-stream; name="v1-0001-Perform-final-failsafe-check-before-truncation.patch" Content-Disposition: attachment; filename="v1-0001-Perform-final-failsafe-check-before-truncation.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_l0sn9lgl0 RnJvbSA3MmFlYmM3ODU0ZDI0ZmI4NDY2YjQ1NTM2ZTQxY2MzZDc2OGNkNDQ1IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBQZX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