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 1ps2zr-0005B0-2J for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Apr 2023 14:53:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ps2zp-0008QO-Qw for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Apr 2023 14:53:21 +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 1ps2zp-0008QD-D1 for pgsql-hackers@lists.postgresql.org; Thu, 27 Apr 2023 14:53:21 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1ps2zi-002Brv-8v for pgsql-hackers@postgresql.org; Thu, 27 Apr 2023 14:53:20 +0000 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-52091c58109so8039446a12.2 for ; Thu, 27 Apr 2023 07:53:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682607193; x=1685199193; 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=uGPy216ETSQSwcYo9/40vLK/QG8L3zOIOMkqV94dEaU=; b=NgQ0G23zZzauTPr8avXKgbtU62BUd4dy6j8dmHFf2GBDz97wsxoBsK/0IeNE1O+dHq Uj5aTfA39Cjuog72JP81T9NhPwbmmIue2qqqtkdUlSZ3wFDahzxs7ROPLRTc/0fO4YYT 1vRUjX5DNlPYK3VoHAxvaSxGfRN+1RpHkUpE6NFvTloSBq6b/p39OS1JBayXJrlOO4qG RyJCH71tjF9/kkN0Ivj+8tVZ46yeETkm5gYaaLBz2cRCRWe38PX8Z5ygz8oEZiMmRJ2Y opOC1regkcoK1ROnfqOp5JWaVdHuu+qNO+Bev3p0JeZpcoAncdOkGIdlAT12sOEdghdZ sHcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682607193; x=1685199193; 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=uGPy216ETSQSwcYo9/40vLK/QG8L3zOIOMkqV94dEaU=; b=OoPMQluFcbX+E7uubxtK3Da6L2Skd5gQ5PO7re0HsF08cEPp8QEDm/ParhvERyGK2M Wuatl7VwsjjaoD4ntCmeANXCO7+3JYD7wc6Mug/wMbyldDFydBLFF2OYILa1rOm+p/2w EnXOPu3V/pwzGSZnqAFAcpU0dme+Jls/KB7rj+OcdW4GnjkNz/3xLGq5AuhkIcRput7h YMA7axZScoQ28r67wBcnFUmwrdHz0yIECLeh7r1Fg5gxT8hqVunZyD7FaG4CiAn78+PP zy2yFcJQUHKSmCtIg6uD9v1NyAnsEr4ME9KqlzxnUmQu9lgechmbqRQWlZKw0LVqz/A0 eBPg== X-Gm-Message-State: AC+VfDwN7B41Xhf+8m1L5FnTF8C4dpiOf4pgKDjqhtDdYwnGaB9as+zD AWAYpJLaLHoZbkqR8pFd/g8GCjgC8m1pIY49gKE= X-Google-Smtp-Source: ACHHUZ7l9eSERrWQtm3goiw0IViEFi9umnEaf/iUnZduMz3l5a+S7jG4YMcPQUUvuIGDu7pX+sGBfmuTBTMN+qll98M= X-Received: by 2002:a17:90a:8a85:b0:23f:81c0:eadd with SMTP id x5-20020a17090a8a8500b0023f81c0eaddmr2122642pjn.47.1682607193205; Thu, 27 Apr 2023 07:53:13 -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: Melanie Plageman Date: Thu, 27 Apr 2023 10:53:01 -0400 Message-ID: Subject: Re: Should vacuum process config file reload more often To: Daniel Gustafsson Cc: Masahiko Sawada , John Naylor , Robert Haas , Andres Freund , Tom Lane , Kyotaro Horiguchi , PostgreSQL Hackers , Amit Kapila 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 On Thu, Apr 27, 2023 at 8:55=E2=80=AFAM Daniel Gustafsson = wrote: > > > On 27 Apr 2023, at 14:10, Masahiko Sawada wrote= : > > > > 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= applied > >>> it with some minor changes to comments and whitespace. Thanks for th= e 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) WIT= H (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 vacuu= med > >> 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.aut= ovacuum_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_m= em" 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 "!VacuumFailsafeActi= ve", > >> fileName=3DfileName@entry=3D0xa4da38 "../src/backend/access/heap/va= cuumlazy.c", lineNumber=3DlineNumber@entry=3D392) at ../src/backend/utils/e= rror/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= =3D0x0, > >> params=3Dparams@entry=3D0x7ffec28585f0, skip_privs=3Dskip_privs@ent= ry=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@ent= ry=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. > > Agreed, that matches my research and testing, I have the same diff here a= nd it > passes testing and works as intended. This was briefly discussed in [0] = and > slightly upthread from there but then missed. I will do some more lookin= g and > testing but I'm fairly sure this is the right fix, so unless I find somet= hing > else I will go ahead with this. > > xid_wraparound is a really nifty testing tool. Very cool.Makes sense to m= e too. Fix LGTM. Though we previously set it to false before this series of patches, perhaps it is worth adding a comment about why VacuumFailsafeActive must be reset here even though we reset it before vacuuming each table? - Melanie