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 1ps0SW-0004m7-Mn for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Apr 2023 12:10:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ps0SU-0008AX-3o for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Apr 2023 12:10:46 +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 1ps0ST-0008AO-NV for pgsql-hackers@lists.postgresql.org; Thu, 27 Apr 2023 12:10:45 +0000 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1ps0SQ-005NG2-7q for pgsql-hackers@postgresql.org; Thu, 27 Apr 2023 12:10:45 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-188090ebf84so1309053fac.1 for ; Thu, 27 Apr 2023 05:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682597438; x=1685189438; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=RpR9mx3rcFcsLDFhqnmuSlyU6TOtkVg5x0goRsbi3BM=; b=iftYIq5xo5VfiUkjbkrqhS8vSozbsvmhjwhGBlv7HTrSZRsiE4xRkUiceMNYQYtV8Y 5JU3ZSGI277hfgS2Ast/ufWQcoYbOac4VyNQfC4K0XCy5xpVIscGlrKlT08F68INZP5z QaROlvGOltmcrKnRga69Pi5ZGlcTiRrLZ07CD277yVJa+Kg9GlPvispTEHPJ2BY86x9r a0ShKhPy7QR2kjaFmx+1l66TxPlY7EBIMlByy0+cHJuRrwAQz70txHKVMJMvl0JnOFd5 W8fHPfOEHdS+zPS9ZEwvj8iRBTbTLKj1H8c54seB1VYRCkIUssfz+ZB9y8/42d5PTf+a LqOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682597438; x=1685189438; h=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=RpR9mx3rcFcsLDFhqnmuSlyU6TOtkVg5x0goRsbi3BM=; b=UowXA2gX1BYVmP1Cn0d6f50y3KszdW315RaBqO0tlArL4tg0caOIyfYC/ikb3DY7JD 7yT9+VfurW/MSL9uDTudqeFRVF8eFL3x9VHXkvo0/2kF5xaekjbDJ7K4zZwi41O01tTv 8DvVHVXD2T2SMdpsk5k+SAtgrjtTlNfFlGCoM1Xm0oStylMF7z4rB5AwetHs/z2DoK+w urIj1+c8xwwU+4XSWE0yia/JgigitAuNTTrK4I8v9wyUIUZVw/QF9p1C6vYAlFkGdC8P 4y7CQvlVktO+n7itEyKF5iwXwvGvgs7y95TOqif4tZ6YHyxpt4cCJ5DjIKPz/dMXIiim zxgA== X-Gm-Message-State: AC+VfDyGHNod77pupobiJgGVRKnf1FuoAUKMY+tgyZZxWvxpoLjBmTAI hdHJIHkC0NKtgt404baMZHbmi58r4NYQUSZTYW4= X-Google-Smtp-Source: ACHHUZ6wcH6qBddD4SuHub+7WvHrGFQ1RnxFUqjH4tNPZl9ZCWQurD8G6ZgiKXSZci0hyYmZgtHn24eqjoMyAoFGGW4= X-Received: by 2002:a05:6870:819d:b0:17e:a596:672f with SMTP id k29-20020a056870819d00b0017ea596672fmr988152oae.4.1682597438010; Thu, 27 Apr 2023 05:10:38 -0700 (PDT) MIME-Version: 1.0 References: <20230329.132155.629765142788133576.horikyota.ntt@gmail.com> <20230329.173456.1185961934810139447.horikyota.ntt@gmail.com> <935191FB-083B-4060-89FC-466F61FAA391@yesql.se> <1252075.1680547394@sss.pgh.pa.us> <20230403190837.qubpnwugfe2k2g46@awork3.anarazel.de> <7E06F879-7E20-4A6A-862F-CA72CDC9A323@yesql.se> <5028847C-937A-4CC2-B127-AFF5F9FB79C5@yesql.se> <2B703533-102A-47E5-A4F7-C6A68C09BB27@yesql.se> In-Reply-To: From: Masahiko Sawada Date: Thu, 27 Apr 2023 21:10:00 +0900 Message-ID: Subject: Re: Should vacuum process config file reload more often To: John Naylor Cc: Daniel Gustafsson , Melanie Plageman , Robert Haas , Andres Freund , Tom Lane , Kyotaro Horiguchi , PostgreSQL Hackers , Amit Kapila Content-Type: multipart/mixed; boundary="00000000000097d1de05fa503ef6" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000097d1de05fa503ef6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 27, 2023 at 6:30=E2=80=AFPM John Naylor wrote: > > > On Fri, Apr 7, 2023 at 6:08=E2=80=AFAM Daniel Gustafsson wrote: > > > > I had another read-through and test-through of this version, and have a= pplied > > it with some minor changes to comments and whitespace. Thanks for the = quick > > turnaround times on reviews in this thread! > > - VacuumFailsafeActive =3D false; > + Assert(!VacuumFailsafeActive); > > I can trigger this assert added in commit 7d71d3dd08. > > First build with the patch in [1], then: > > session 1: > > CREATE EXTENSION xid_wraparound ; > > CREATE TABLE autovacuum_disabled(id serial primary key, data text) WITH (= autovacuum_enabled=3Dfalse); > INSERT INTO autovacuum_disabled(data) SELECT generate_series(1,1000); > > -- I can trigger without this, but just make sure it doesn't get vacuumed > BEGIN; > DELETE FROM autovacuum_disabled WHERE id % 2 =3D 0; > > session 2: > > -- get to failsafe limit > SELECT consume_xids(1*1000*1000*1000); > INSERT INTO autovacuum_disabled(data) SELECT 1; > SELECT consume_xids(1*1000*1000*1000); > INSERT INTO autovacuum_disabled(data) SELECT 1; > > VACUUM autovacuum_disabled; > > WARNING: cutoff for removing and freezing tuples is far in the past > HINT: Close open transactions soon to avoid wraparound problems. > You might also need to commit or roll back old prepared transactions, or = drop stale replication slots. > WARNING: bypassing nonessential maintenance of table "john.public.autova= cuum_disabled" as a failsafe after 0 index scans > DETAIL: The table's relfrozenxid or relminmxid is too far in the past. > HINT: Consider increasing configuration parameter "maintenance_work_mem"= or "autovacuum_work_mem". > You might also need to consider other ways for VACUUM to keep up with the= allocation of transaction IDs. > server closed the connection unexpectedly > > #0 0x00007ff31f68ebec in __pthread_kill_implementation () > from /lib64/libc.so.6 > #1 0x00007ff31f63e956 in raise () from /lib64/libc.so.6 > #2 0x00007ff31f6287f4 in abort () from /lib64/libc.so.6 > #3 0x0000000000978032 in ExceptionalCondition ( > conditionName=3DconditionName@entry=3D0xa4e970 "!VacuumFailsafeActive= ", > fileName=3DfileName@entry=3D0xa4da38 "../src/backend/access/heap/vacu= umlazy.c", lineNumber=3DlineNumber@entry=3D392) at ../src/backend/utils/err= or/assert.c:66 > #4 0x000000000058c598 in heap_vacuum_rel (rel=3D0x7ff31d8a97d0, > params=3D, bstrategy=3D) > at ../src/backend/access/heap/vacuumlazy.c:392 > #5 0x000000000069af1f in table_relation_vacuum (bstrategy=3D0x14ddca8, > params=3D0x7ffec28585f0, rel=3D0x7ff31d8a97d0) > at ../src/include/access/tableam.h:1705 > #6 vacuum_rel (relid=3Drelid@entry=3D16402, relation=3Drelation@entry=3D= 0x0, > params=3Dparams@entry=3D0x7ffec28585f0, skip_privs=3Dskip_privs@entry= =3Dtrue, > bstrategy=3Dbstrategy@entry=3D0x14ddca8) > at ../src/backend/commands/vacuum.c:2202 > #7 0x000000000069b0e4 in vacuum_rel (relid=3D16398, relation=3D, > params=3Dparams@entry=3D0x7ffec2858850, skip_privs=3Dskip_privs@entry= =3Dfalse, > bstrategy=3Dbstrategy@entry=3D0x14ddca8) > at ../src/backend/commands/vacuum.c:2236 Good catch. I think the problem is that vacuum_rel() is called recursively and we don't reset VacuumFailsafeActive before vacuuming the toast table. I think we should reset it in heap_vacuum_rel() instead of Assert(). It's possible that we trigger the failsafe mode only for either one.Please find the attached patch. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com --00000000000097d1de05fa503ef6 Content-Type: application/octet-stream; name="reset_VacuumFailsafeActive.patch" Content-Disposition: attachment; filename="reset_VacuumFailsafeActive.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lgz2xq5k0 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL2FjY2Vzcy9oZWFwL3ZhY3V1bWxhenkuYyBiL3NyYy9i YWNrZW5kL2FjY2Vzcy9oZWFwL3ZhY3V1bWxhenkuYwppbmRleCAwYTllYmQyMmJkLi4yYmE4NWJk M2Q2IDEwMDY0NAotLS0gYS9zcmMvYmFja2VuZC9hY2Nlc3MvaGVhcC92YWN1dW1sYXp5LmMKKysr IGIvc3JjL2JhY2tlbmQvYWNjZXNzL2hlYXAvdmFjdXVtbGF6eS5jCkBAIC0zODksNyArMzg5LDcg QEAgaGVhcF92YWN1dW1fcmVsKFJlbGF0aW9uIHJlbCwgVmFjdXVtUGFyYW1zICpwYXJhbXMsCiAJ QXNzZXJ0KHBhcmFtcy0+aW5kZXhfY2xlYW51cCAhPSBWQUNPUFRWQUxVRV9VTlNQRUNJRklFRCk7 CiAJQXNzZXJ0KHBhcmFtcy0+dHJ1bmNhdGUgIT0gVkFDT1BUVkFMVUVfVU5TUEVDSUZJRUQgJiYK IAkJICAgcGFyYW1zLT50cnVuY2F0ZSAhPSBWQUNPUFRWQUxVRV9BVVRPKTsKLQlBc3NlcnQoIVZh Y3V1bUZhaWxzYWZlQWN0aXZlKTsKKwlWYWN1dW1GYWlsc2FmZUFjdGl2ZSA9IGZhbHNlOwogCXZh Y3JlbC0+Y29uc2lkZXJfYnlwYXNzX29wdGltaXphdGlvbiA9IHRydWU7CiAJdmFjcmVsLT5kb19p bmRleF92YWN1dW1pbmcgPSB0cnVlOwogCXZhY3JlbC0+ZG9faW5kZXhfY2xlYW51cCA9IHRydWU7 Cg== --00000000000097d1de05fa503ef6--