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 1jaZRx-0004c9-Um for pgsql-general@arkaria.postgresql.org; Mon, 18 May 2020 06:40:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jaZRw-0005n9-PG for pgsql-general@arkaria.postgresql.org; Mon, 18 May 2020 06:40:32 +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 1jaZRw-0005ky-Fn for pgsql-general@lists.postgresql.org; Mon, 18 May 2020 06:40:32 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jaZRt-0007Fd-5J for pgsql-general@postgresql.org; Mon, 18 May 2020 06:40:30 +0000 Received: by mail-wr1-x441.google.com with SMTP id l18so10357568wrn.6 for ; Sun, 17 May 2020 23:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=YqMjHUHd6WRKYorkfPmCPsjd0Fa2yyZEkKTy4gt22Mc=; b=d9sZm7lZKDTxzIDjRkxNBZxgDDMEsTzAufgm3uHHYOXmCDkgQwOhSnRz7qpqC/uIRa 4vtnnUM1fhOnARziRdMEB87SZlZRXkms1hkZ/0DxLa5JHaOJemiT/0/Xq0ZKHbsF9oAj 9NBPIxbCRMcY4Fj+jESWu5/TAUG0fFTH+fXoOjlMtQYE1YNT5CvCKpCRNn4rYuu66A1i dGmO1VZHEDNK+Y5PbnbmnpwUwkNWE9suUUCARFvjZa81ulZqMWlfjqHjAtTmHy25yvsB 8uFKx+67FTRjex9Ggls+monNk2wLWN569uZUyxWcaOJ2uTw9CSlYFTGB4J5Oie6nRICU n0Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=YqMjHUHd6WRKYorkfPmCPsjd0Fa2yyZEkKTy4gt22Mc=; b=U2jaCwdE13i6JotTF1+8IX0VCg++Hb2pYY2CCR4LOp2Lan0RzcO/WhV65iFsoR+yGA ds202Nxnqe+Khi6efvlw/uri1BU287X+SHkxbef31DN39BXOu7a+VM6/kPo2t8R4fXhG X8+umOSyzJJ51/F6rcq25HugXpXClEO/0cNIsjZqvlepMpMc/Fp3ABTkchVAHSKXHn2c ElvujabdYvMXauuZ7i+A6is0dtlQpqk4hN+wpJ7UsacCCnDBWX2PHPiPwa7VIxcEdyZ+ CcVnWSflFrMtAG9lG6Zh41q5V1FtRyYbAxcIfuBLBOumoWend33Anbf1qCgj+I0bxvfy Ssog== X-Gm-Message-State: AOAM530uKWWXxgKbjze8G50SkiCcaDU2wv6ZQEYVunXSKU7dq1rjdKZb XRi1W83YFSau6VLqbLV5ZCK4C8fKaLQ= X-Google-Smtp-Source: ABdhPJw3WNoUfpVrHaV7Y8is2uQeObo3lhwNfRl2hjMc0pHINL5l1JXmXCi6Ne82Jog41ocVpVsG2Q== X-Received: by 2002:a5d:42c9:: with SMTP id t9mr18646321wrr.246.1589784027631; Sun, 17 May 2020 23:40:27 -0700 (PDT) Received: from localhost.localdomain (217-149-172-219.nat.highway.telekom.at. [217.149.172.219]) by smtp.gmail.com with ESMTPSA id i21sm14097550wml.5.2020.05.17.23.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2020 23:40:27 -0700 (PDT) Message-ID: Subject: Re: template0 needing vacuum freeze? From: Laurenz Albe To: Don Seiler , Postgres General Date: Mon, 18 May 2020 08:40:26 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, 2020-05-16 at 12:19 -0500, Don Seiler wrote: > PG 9.6 (9.6.8). Got an alert today when template0 and template1 were both over 50% > towards TXID wraparound. I could vacuum template1 but couldn't vacuum template0 > without first allowing connections. This is what it looked like before: > > # SELECT datname > , age(datfrozenxid) > , current_setting('autovacuum_freeze_max_age') > FROM pg_database > ORDER BY 2 DESC; > datname | age | current_setting > --------------------+------------+----------------- > foo_db | 1022106099 | 200000000 > template0 | 1000278345 | 200000000 > postgres | 643729 | 200000000 > template1 | 643729 | 200000000 > (4 rows) > > I've since allowed connections and ran "vacuumdb --freeze" on it and then immediately > disabled the connections to it again. But I'm curious how template0 would be growing > in age like this. Even now I see the template0 age growing. That is indeed strange. Did you see any weird messages when you vacuumed "template0"? Did "datfrozenxid" shrink after the operation? "foo_db" seems to be the bigger problem. Perhaps autovacuum never handled "template0" because it concluded (rightly) that it has to deal with "foo_db" first. > I can say that these DB > has previously been altered for locale changes as well. Would you care to explain that? You changed "template0"? How? > I'm also running a long "vacuum freeze" on foo_db that will take a few days after > seeing that autovacuum on a big table had been running on it since Feb 2 and making > no progress, with over 850M dead tuples according to pg_stat_all_tables. > I estimate 3-4 more days to go on that one. Once that's done I'll be scheduling > manual vacuum jobs. Just wondering if that would somehow affect regular template0 > cleanup though. As I said, perhaps. What are your non-default autovacuum settings? Perhaps you should speed up autovacuum by reducing "autovacuum_vacuum_cost_delay" to 2ms or less, and by increasing "maintenance_work_mem". Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com