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 1ovABy-00068m-M5 for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Nov 2022 04:38:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ovABx-000306-E0 for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Nov 2022 04:38:29 +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 1ovABx-0002zj-2R for pgsql-hackers@lists.postgresql.org; Wed, 16 Nov 2022 04:38:29 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ovABq-0007Vr-Qu for pgsql-hackers@postgresql.org; Wed, 16 Nov 2022 04:38:28 +0000 Received: by mail-pl1-x634.google.com with SMTP id g24so15366507plq.3 for ; Tue, 15 Nov 2022 20:38:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=71m5qOuDbsiRfUHDP6FXAucMO9Lr3d7XG3NQ/b+vdDw=; b=NPREvDzI/JxfZAe9OpiFaEyfoENQHlTlaC0FBmiGES5W2dlRsuyq/YUFoCLoXahanK 3oZa757o43quOJdjKxw//o9bPRYITJCDVukpMRchrnKCDBUG2yq4SqrdSntLLtxB1aee GtRlc/f4QxUIDb2yZyA/4g5wBtpQemQjaw69ZELfRpLQuyISmOz6x4s5MdeU4bm1rmFf oHBgSQ5+SlldNeY6h0tgzanHrfbZSiJ6XiVLMRc3WvWssBNL5UysdNgRby/vt1Cy6Mkv mC7Tdt4YwO0oHkeLEtL13d7QCcouPtNCGv/+hMGZBMopjlV1ZzRQluVY9krPGFkXLtb2 jZQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=71m5qOuDbsiRfUHDP6FXAucMO9Lr3d7XG3NQ/b+vdDw=; b=hyrBxmIVlsykbEupJ4y6WIImfUj8vhFjMhUbqnFe1rY5yP1sT9saZUdsmL9ahBWwZ9 sSyPFdr4xp9Vd61QIW5rvbQNlFGukBHU/wBu5xZxWd3oIi4CvCj4OOSsJc3Vzc4vSaxG ra/Nk461IuYoVHCPqSNmESuUK7KhFZoVHAFCH4FSG0TYEBHaUKxmFt2+Gtv7EVFda9dh y68X65yQ9yVHGlREVsImP8G57xM8HO5CBem2k6RFW3NSEcYIqbOx9WIikQawH3VTwxYy Bj0BVYKQsoqsnrqscucbCyj3OOgLFA0RsoYskTeEAvZCXcjf2Jwfmaz3fWulC/Pm8+rd iJVA== X-Gm-Message-State: ANoB5plC10VvuTs0BSvNrP7v1w4HeE5KiPAVrNcHCcOXPt8Ygz2/AiEA aSPTrQUpw+HsoYdd+ZyyeXQCItsjo7NEq+NohDg= X-Google-Smtp-Source: AA0mqf4Z/sGBXfALNVewj6Kd8p2/BDpzVij8eMxZMPjyryzXRZX/TfdxbhpR95kRs3fgjWiXTgrT0nQutwyT+zFChqk= X-Received: by 2002:a17:90a:f48d:b0:212:c877:e948 with SMTP id bx13-20020a17090af48d00b00212c877e948mr1924783pjb.39.1668573501550; Tue, 15 Nov 2022 20:38:21 -0800 (PST) MIME-Version: 1.0 References: <20210423204306.5osfpkt2ggaedyvy@alap3.anarazel.de> <20210611011850.detxnd7bnffg3daz@alap3.anarazel.de> In-Reply-To: From: Ian Lawrence Barwick Date: Wed, 16 Nov 2022 13:38:10 +0900 Message-ID: Subject: Re: Testing autovacuum wraparound (including failsafe) To: Masahiko Sawada Cc: Andres Freund , Anastasia Lubennikova , pgsql-hackers , Peter Geoghegan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 2022=E5=B9=B46=E6=9C=8830=E6=97=A5(=E6=9C=A8) 10:40 Masahiko Sawada : > > Hi, > > On Tue, Feb 1, 2022 at 11:58 AM Masahiko Sawada w= rote: > > > > On Fri, Jun 11, 2021 at 10:19 AM Andres Freund wro= te: > > > > > > Hi, > > > > > > On 2021-06-10 16:42:01 +0300, Anastasia Lubennikova wrote: > > > > Cool. Thank you for working on that! > > > > Could you please share a WIP patch for the $subj? I'd be happy to h= elp with > > > > it. > > > > > > I've attached the current WIP state, which hasn't evolved much since > > > this message... I put the test in src/backend/access/heap/t/001_emerg= ency_vacuum.pl > > > but I'm not sure that's the best place. But I didn't think > > > src/test/recovery is great either. > > > > > > > Thank you for sharing the WIP patch. > > > > Regarding point (1) you mentioned (StartupSUBTRANS() takes a long time > > for zeroing out all pages), how about using single-user mode instead > > of preparing the transaction? That is, after pg_resetwal we check the > > ages of datfrozenxid by executing a query in single-user mode. That > > way, we don=E2=80=99t need to worry about autovacuum concurrently runni= ng > > while checking the ages of frozenxids. I=E2=80=99ve attached a PoC patc= h that > > does the scenario like: > > > > 1. start cluster with autovacuum=3Doff and create tables with a few dat= a > > and make garbage on them > > 2. stop cluster and do pg_resetwal > > 3. start cluster in single-user mode > > 4. check age(datfrozenxid) > > 5. stop cluster > > 6. start cluster and wait for autovacuums to increase template0, > > template1, and postgres datfrozenxids > > The above steps are wrong. > > I think we can expose a function in an extension used only by this > test in order to set nextXid to a future value with zeroing out > clog/subtrans pages. We don't need to fill all clog/subtrans pages > between oldestActiveXID and nextXid. I've attached a PoC patch for > adding this regression test and am going to register it to the next > CF. > > BTW, while testing the emergency situation, I found there is a race > condition where anti-wraparound vacuum isn't invoked with the settings > autovacuum =3D off, autovacuum_max_workers =3D 1. AN autovacuum worker > sends a signal to the postmaster after advancing datfrozenxid in > SetTransactionIdLimit(). But with the settings, if the autovacuum > launcher attempts to launch a worker before the autovacuum worker who > has signaled to the postmaster finishes, the launcher exits without > launching a worker due to no free workers. The new launcher won=E2=80=99t= be > launched until new XID is generated (and only when new XID % 65536 =3D=3D > 0). Although autovacuum_max_workers =3D 1 is not mandatory for this > test, it's easier to verify the order of operations. Hi Thanks for the patch. While reviewing the patch backlog, we have determined= that the latest version of this patch was submitted before meson support was implemented, so it should have a "meson.build" file added for consideration= for inclusion in PostgreSQL 16. Regards Ian Barwick