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.92) (envelope-from ) id 1jEKrx-0000nJ-II for pgsql-general@arkaria.postgresql.org; Tue, 17 Mar 2020 22:39:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jEKrw-0000yS-9p for pgsql-general@arkaria.postgresql.org; Tue, 17 Mar 2020 22:39:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jEKru-0000yF-Nk for pgsql-general@lists.postgresql.org; Tue, 17 Mar 2020 22:39:28 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jEKrj-0002l7-BA for pgsql-general@lists.postgresql.org; Tue, 17 Mar 2020 22:39:24 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 67B0B536; Tue, 17 Mar 2020 18:39:10 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 17 Mar 2020 18:39:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=0 XhvGJj5YVTLCFMnyVVze6w9nVrOykSKs8synq+Z6CI=; b=ummZRbqCKr1uWA7qv BQQVrEuHeI3tMBHzutIk798VLO9tEFHSD3DCjoj81lXwfSpTptccC92yD7JNYqih rjoySDKpGbMwHhBNDsqVrEL70jICYu4Uj/DiZb2sBOI61nLwD1TJEM5W+NoR2BgV LDnC9aKuFzZ6SFP+mi3igeFOgq+qZ+/gO5wUNGpZzEGR+p0heNx1IGfof/usrk+4 UB8m0ea86xh2sWIjcLKgad6EQx3t0QPqHp6nMCGzLopyx4CoX6Vw05I8enlrfK3J k/L5wzXrhDa7FUb3TS23zv/RfHBtp51U8f2wtu9N1oq52L+5/PIS2gjWu+ELxWtY JnCDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding: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=0XhvGJj5YVTLCFMnyVVze6w9nVrOykSKs8synq+Z6 CI=; b=zGHuHkQ3T9JNYSYc+SKvDvQYwzvlkVDBVq2geL11CY19Jo2dmzF0XnXde EG6Fj+lJoXvgC5cFrbtEHexzMtAufzyiToWjgz/mubqUcy3A4QFXjl73MhcDF0Ev WPzrz731FfzgtllQFFbNrdRdawvHxqq/Z/+oJ6vZAGVPOfPH/pOwT1TlXTl9d+d+ 4YQdtotTHe3+IeXgO0FOZh/ZC2Psj8GQSgneNuGz91uGt1Q+teGT7LBTnFf/oat5 cdlFAXcf4vSkFT4yD/4Uup6guQfSy1wholouyQsvNMp/NT3zqMUJLDy0HooNypEu pNiNPebba9FSdNkfRv1sSdyQ42f4Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrudefhedgudehhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghdpfhhlihhghhhtrgif rghrvgdrtghomhenucfkphepjedurddvuddvrdduvdelrdduleefnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgv rhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id 6DAAA3280064; Tue, 17 Mar 2020 18:39:09 -0400 (EDT) Subject: Re: Fwd: PG12 autovac issues To: Justin King , pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: Date: Tue, 17 Mar 2020 15:39:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/17/20 3:22 PM, Justin King wrote: > Apologies, I accidentally sent this to the pgsql-admin list initially > but intended it go here: > > We have a database that isn't overly large (~20G), but gets incredibly > frequent updates. Here's an example table: > > feedi=# select * from pg_stat_all_tables where schemaname = > 'production' and relname = 'tita'; > relid = 16786 > schemaname = production > relname = tita > seq_scan = 23365 > seq_tup_read = 403862091 > idx_scan = 26612759248 > idx_tup_fetch = 19415752701 > n_tup_ins = 24608806 > n_tup_upd = 4207076934 > n_tup_del = 24566916 > n_tup_hot_upd = 4073821079 > n_live_tup = 79942 > n_dead_tup = 71969 > n_mod_since_analyze = 12020 > last_vacuum = 2020-03-17 15:35:19.588859+00 > last_autovacuum = 2020-03-17 21:31:08.248598+00 > last_analyze = 2020-03-17 15:35:20.372875+00 > last_autoanalyze = 2020-03-17 22:04:41.76743+00 > vacuum_count = 9 > autovacuum_count = 135693 > analyze_count = 9 > autoanalyze_count = 495877 > > As you can see in this table, there are only ~80K rows, but billions > of updates. What we have observed is that the frozenxid reaches the > 200M mark fairly quickly because of the amount of activity. What is > interesting is that this happens with the 'postgres' and 'template1' > databases as well and there is absolutely no activity in those > databases. > > When the 'postgres' and/or 'template1' databases hit the > freeze_max_age, there are cases where it kicks off an aggressive > autovac of those tables which seems to prevent autovacs from running > elsewhere. Oddly, this is not consistent, but that condition seems to > be required. We have observed this across multiple PG12 servers (dev, > test, staging, production) all with similar workloads. Is there anything in postgres and template1 besides what was created at init? What are your settings for autovacuum?: https://www.postgresql.org/docs/12/runtime-config-autovacuum.html > > $ grep -i vacuum /var/log/postgresql/postgres.log | cut -b 1-9 | uniq -c > 17 Mar 17 06 > 34 Mar 17 07 > 31 Mar 17 08 > 31 Mar 17 09 > 30 Mar 17 10 > 34 Mar 17 11 > 33 Mar 17 12 > 19 Mar 17 13 > 40 Mar 17 15 > 31 Mar 17 16 > 36 Mar 17 17 > 34 Mar 17 18 > 35 Mar 17 19 > 35 Mar 17 20 > 33 Mar 17 21 > > As you can see above, we end up having around ~33 autovac/hr, and > about 13:30 today, they stopped until we ran a "vacuum freeze verbose > analyze;" against the 'postgres' database (around 15:30) which then > caused the autovacs to resume running against the "feedi" database. > > I'm completely perplexed as to what is happening and why it suddenly > started when we moved from PG10 > PG12. The configs and workload are > essentially the same between versions. We realize we could simply > increase the autovacuum_freeze_max_age, but that doesn't seem to > actually resolve anything -- it just pushes the problem out. Has > anyone seen anything similar to this? > > Thanks very much for the consideration. > > Justin King > http://flightaware.com/ > > -- Adrian Klaver adrian.klaver@aklaver.com