Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9q3C-0007Yr-L9 for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2019 11:51:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h9q39-0002ut-O5 for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2019 11:51:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9q38-0002nB-K6 for pgsql-hackers@lists.postgresql.org; Fri, 29 Mar 2019 11:51:55 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9q33-0006Wu-I1 for pgsql-hackers@lists.postgresql.org; Fri, 29 Mar 2019 11:51:53 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id F376C21C93; Fri, 29 Mar 2019 07:51:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 29 Mar 2019 07:51:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=BsrTlJyfTbjDDWRbC07hqbkzevK LF4Uxplw5kPyYc6E=; b=u3L/G61OjR9etW0AhGy5RtvORw9H7LKLa2uS9UT1hhJ SN7gOXmUIM3zN6femn9+3hhrnigXqARzKUtM7seI4jQvERauGaeECBA2galyL1qZ TdS3J6PGKBvfZQNA/dXzOuCjb3dpgQ5GQXQDhnqw1744gn0Rh1MVQH+OB/riG0qV eck/C2XQcUlZLFuGmwyrtn2UJl883qc8VFStu+IXBcBnEzSK0I+/3gnOCurexsHp rxVpShbMpKYMqamFkXXfiQBeD00Wm1Gt2QJR66P9MQW9eZiqzBg3Ow+YGpSsq2Um 64UeETnTTUxo+FC7PUnjnYmx9PceCz1kyRoNLGIqVDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=BsrTlJ yfTbjDDWRbC07hqbkzevKLF4Uxplw5kPyYc6E=; b=fcUURPmGx4v5LU3BoHLqVU WcSWhqPcyOpor1ESoAhuxRuNVoVnFBxMSQYhph4DccPIK8UIIAb2KpKfDNWjG3T0 ZBukXjlLhj7qJJAKKWV+324SqLxo3BiuYdIyhrq8zsPMACh93ZP8kYpmzLWZuQMu Odh8Kpnm4YpZH9x11+G25Kjd8ZtBWUse/DhkJk1+3Rv8jx1xjaxANcgPIUOAtdwE AH6cJ7xX7JILXRU/g0/zHQmHxy369RGKCn+K1N4yfQF4xxu75EzdJ2kOz8roxsyD YwVXNfsVltMqIIkZVc1qNcUVW40TSOT07aMJe4Q8dtvOuFF0Zv2TH7EsRohxrg4g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrkeejgddtiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecukfhppeeiuddrvdduhedrudefjedrudeivdenucfrrghrrghm pehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiienucevlhhush htvghrufhiiigvpedt X-ME-Proxy: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 4C58D1031A; Fri, 29 Mar 2019 07:51:42 -0400 (EDT) Date: Fri, 29 Mar 2019 20:51:38 +0900 From: Michael Paquier To: Andrew Dunstan Cc: Kyotaro HORIGUCHI , sawada.mshk@gmail.com, tgl@sss.pgh.pa.us, alvherre@2ndquadrant.com, sk@zsrv.org, nasbyj@amazon.com, andres@anarazel.de, robertmhaas@gmail.com, pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: Improve autovacuum logging for aggressive and anti-wraparound ru Message-ID: <20190329115138.GD1954@paquier.xyz> References: <20181005031603.GF1629@paquier.xyz> <20181005063504.GB14664@paquier.xyz> <20181009.181536.142257785.horiguchi.kyotaro@lab.ntt.co.jp> <920b7f84-407c-005c-4b7d-e8266a17d22b@2ndQuadrant.com> <20190309011537.GD9266@paquier.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="d8Lz2Tf5e5STOWUP" Content-Disposition: inline In-Reply-To: <20190309011537.GD9266@paquier.xyz> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --d8Lz2Tf5e5STOWUP Content-Type: multipart/mixed; boundary="OROCMA9jn6tkzFBc" Content-Disposition: inline --OROCMA9jn6tkzFBc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Mar 09, 2019 at 10:15:37AM +0900, Michael Paquier wrote: > I am adding an open item about that. I think I could commit the > patch, but I need to study it a bit more first. So, coming back to this thread, and studying the problem again, it looks that the diagnostic that a non-aggressive, anti-wraparound vacuum could be triggered because the worker sees trouble in the force because of some activity happening in parallel. Hence, if we face this case, it looks right to skip the vacuum for this relation. Attached is an updated patch with a better error message, more comments, and the removal of the anti-wraparound non-aggressive log which was added in 28a8fa9. The error message could be better I guess. Suggestions are welcome. Thoughts? -- Michael --OROCMA9jn6tkzFBc Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="autovac-antiwrap-skip.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap= /vacuumlazy.c index 5c554f9465..82be8c81f3 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -248,6 +248,25 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params, if (params->options & VACOPT_DISABLE_PAGE_SKIPPING) aggressive =3D true; =20 + /* + * When running an anti-wraparound vacuum, we expect relfrozenxid to be + * old enough so as aggressive is always set. If this is not the case, + * it could be possible that another concurrent vacuum process has done + * the work for this relation so that relfrozenxid in relcache has + * already been moved forward enough, causing this vacuum run to be + * non-aggressive. If that happens, note that this relation no longer + * needs to be vacuumed, so just skip it. + */ + if (params->is_wraparound && !aggressive) + { + ereport(LOG, + (errmsg_internal("found vacuum to prevent wraparound of table \"%s.%s.= %s\" to be not aggressive, so skipping", + get_database_name(MyDatabaseId), + get_namespace_name(RelationGetNamespace(onerel)), + RelationGetRelationName(onerel)))); + return; + } + vacrelstats =3D (LVRelStats *) palloc0(sizeof(LVRelStats)); =20 vacrelstats->old_rel_pages =3D onerel->rd_rel->relpages; @@ -375,10 +394,9 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params, initStringInfo(&buf); if (params->is_wraparound) { - if (aggressive) - msgfmt =3D _("automatic aggressive vacuum to prevent wraparound of ta= ble \"%s.%s.%s\": index scans: %d\n"); - else - msgfmt =3D _("automatic vacuum to prevent wraparound of table \"%s.%s= =2E%s\": index scans: %d\n"); + /* an anti-wraparound vacuum has to be aggressive */ + Assert(aggressive); + msgfmt =3D _("automatic aggressive vacuum to prevent wraparound of tab= le \"%s.%s.%s\": index scans: %d\n"); } else { --OROCMA9jn6tkzFBc-- --d8Lz2Tf5e5STOWUP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlyeBsoACgkQnvQgOdby QH0a1A//cmganeiY/BHrUI24k1VkK0OBjWypK1thwQ2rGGzZYEc+MiazNLFxyEJs S+Wa1DQ1YKQ8O/D9GiTIQsmmZM60WF2TlXOMfvlqaZzdj/zSsUoZv23UsbeqM8I/ CdNlgxesWeqRz87GkA0dJ+pCTdb8sBQSctEzCLCS3gxlhtxf+nhd38nobNc3y92C /3z246G9QL8Mj994VIz5L5Sd3fDKHiUNr0k5wMO3lGf/QbH4vVF/C5t24TxybEEg MXgB+qLMnn83At5zK0pW5pOnoIkD7t2zALbKNMGj07p5qmffnOphDeWWXH38gSyL YClzQrDviP0Mq5vjqME82XnAjlMetPCleEK4cxlwEWJf21woRGnEse4bBDCNzJx1 KLxcPhIvP5iCdQorQcOBdEYx21tuRWsTjWRR3t5e8x3//y8lDlmFntY+LLd3R52M cia43FsHPaxu+A5dQ+SAn9WXwKqK6/cDHhAMC3TwmcTYvXI5dtb027OC4ZmgU92d WHgC3hcQRme21rVrPq2jfbWViyODbvSFFCm4gBwEmufqrozfpxXLiN/CfJ+ALOEg n7ZTEyWHvwb/FtCa1KWRTuqrVWEfgKzYG3DqVkdUAXuDYHSKBIjEAZKb7B+ThnIH e0yRGTqdKUJjbA9mpxXRRkLYzcrqSjIlKB5Du77MhlJHL2yvcE0= =11jD -----END PGP SIGNATURE----- --d8Lz2Tf5e5STOWUP--