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 1lSFAw-0003Hl-PN for pgsql-general@arkaria.postgresql.org; Fri, 02 Apr 2021 08:29:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lSFAv-0003kU-OT for pgsql-general@arkaria.postgresql.org; Fri, 02 Apr 2021 08:29:05 +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 1lSFAv-0003kM-9R for pgsql-general@lists.postgresql.org; Fri, 02 Apr 2021 08:29:05 +0000 Received: from mail1.dalibo.net ([212.83.143.11] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lSFAs-00075m-Ka for pgsql-general@lists.postgresql.org; Fri, 02 Apr 2021 08:29:04 +0000 Received: from firost (larco.ioguix.net [78.202.0.6]) by mail.dalibo.com (Postfix) with ESMTPSA id 5478A206BE; Fri, 2 Apr 2021 10:29:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1617352141; bh=OcErwk4eLXn9YnJoAeUuAPlbbiL8XE64IZBOQ0MSLh4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=F0ZBwJhoPAP5OY5qgKM/IYOa9/YFMRagwXKu7I+su0ESQZM2Whz8ZhTiUYowwI5Pl 1V48e561v3HYVn3cTAISlWeaj4frkiR7eaTCYz2Ol58fp657DsBJCDxA2jnTv51VXV WotafZAJE1TMUjLFX6DfjGGRLIf+tGwUZ1Q0IfP4= Date: Fri, 2 Apr 2021 10:29:00 +0200 From: Jehan-Guillaume de Rorthais To: Luca Ferrari Cc: pgsql-general Subject: Re: questions about wraparound Message-ID: <20210402102900.7ae6e665@firost> In-Reply-To: References: Organization: Dalibo MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 18 Mar 2021 09:56:16 +0100 Luca Ferrari wrote: [...] > Therefore my question is: shouldn't autovacuum be able to freeze other > tables/databases? I mean, the wraparound problem in this scenario will > cause problems, but I was expecting different numbers for different > tables/databases. In fact, when an autovacuum worker is spawned, here is how it chooses what database to process: 1. look for any database needing a vacuum to prevent a wraparound. 2. same with multi-transaction 3. other autovacuum considerations So as long as there's a database in desperate need for a vacuum to prevent a wraparound, a worker will try to process it first, again and again. Because of your long-running transaction, the xid horizon forbid to update the rel/datfrozenxid. So next autovacuum round will keep trying to process the same database, ignoring others. Look at the comment in function "do_stat_worker()" in autovacuum.c for more details: https://git.postgresql.org/cgit/postgresql.git/tree/src/backend/postmaster/autovacuum.c#n1207 When looping over the database list, as soon as "for_xid_wrap" is true, any other database is ignored. Then a new worker is popped from the freeWorkers, init'ed with the database to freeze and started. So as far as I understand the code (I might easily be wrong), all the workers will keep trying to process the same database again and again without considering other ones. All because of your really-long living xact. Regards,