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 1o6see-0000gE-Mz for pgsql-admin@arkaria.postgresql.org; Thu, 30 Jun 2022 11:48:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o6seb-0006VC-UT for pgsql-admin@arkaria.postgresql.org; Thu, 30 Jun 2022 11:48:13 +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 1o6seb-0006SB-EK for pgsql-admin@lists.postgresql.org; Thu, 30 Jun 2022 11:48:13 +0000 Received: from forwardcorp1o.mail.yandex.net ([2a02:6b8:0:1a2d::193]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o6seY-0001uz-5E for pgsql-admin@lists.postgresql.org; Thu, 30 Jun 2022 11:48:12 +0000 Received: from myt6-79704c0e15e4.qloud-c.yandex.net (myt6-79704c0e15e4.qloud-c.yandex.net [IPv6:2a02:6b8:c12:239b:0:640:7970:4c0e]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id 716D52E0974; Thu, 30 Jun 2022 14:48:07 +0300 (MSK) Received: from myt6-81d8ab6a9f9d.qloud-c.yandex.net (myt6-81d8ab6a9f9d.qloud-c.yandex.net [2a02:6b8:c12:520a:0:640:81d8:ab6a]) by myt6-79704c0e15e4.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id m5nDs1Y1zw-m7KW8bMf; Thu, 30 Jun 2022 14:48:07 +0300 X-Yandex-Fwd: 2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1656589687; bh=d7CKUkht3FUqZGddtlEgB5TCQMIp1qZ4P5K7uMUA2ds=; h=Message-Id:References:Date:Cc:In-Reply-To:Subject:To:From; b=DdJwDsgGJV4SiwxmAM3xvzyq8yMfxvCiM/cqnGckj9euueC9E1WnqWJW3zDxIn6PQ zlorh3D0/UCIXUq5xB5qwkTPdfvt0CJ/aTkE/vKfjOgqQV9NkZ5tliw1/mEUVAl+31 macrC9lEXr/fUzgoozybKtH7ilbqdPU1rdA+1RlY= Authentication-Results: myt6-79704c0e15e4.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from smtpclient.apple (unknown [2a02:6b8:82:604:390a:9b28:7434:6e04]) by myt6-81d8ab6a9f9d.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id hJZdhPOnST-m7MK7Qj6; Thu, 30 Jun 2022 14:48:07 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.60.0.1.1\)) Subject: Re: Long running backup preventing auto vacuum From: Andrey Borodin In-Reply-To: Date: Thu, 30 Jun 2022 16:48:06 +0500 Cc: Pgsql-admin Content-Transfer-Encoding: quoted-printable Message-Id: <8E8CD661-4779-493A-9DA8-F02CFC007757@yandex-team.ru> References: To: Nikhil Shetty X-Mailer: Apple Mail (2.3693.60.0.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi! > On 30 Jun 2022, at 14:23, Nikhil Shetty = wrote: >=20 > Hi, >=20 > PostgreSQL version - 11.7 >=20 > We are using wal-g for backup/restore. We had a duration of high WAL = generation due to application usage due to which archive backup was = delayed.=20 >=20 > Backup was started through cron schedule and it didn't complete = because it waits for the last WAL to be archived. Now, I know that long = running transactions will prevent vacuuming of dead tuples but in this = case we were able to run manual vacuums successfully but auto-vacuum = never starts. >=20 > As soon as we terminated the long running backup session, the = auto-vacuum started kicking in. >=20 > Wanted to understand why a backup operation is blocking the = auto-vacuum? >=20 > Wal-g uses non-exclusive backups and waits for the last wal to be = archived. As far as I know, WAL-G should not prevent running autovacuums on = tables. WAL-G can be run against replication standby, where vacuum is = not possible at all, so there must be no conflicts... The only probable problem I can imagine is that we open transaction = during pg_stop_backup() [0] to set a statement_timeout. I think this is = superflous and unneeded. I think this tx can be safely removed. But = anyway, this tx does not have a xid (otherwise it could not run on = Standby). BTW which version of WAL-G do you use? Best regards, Andrey Borodin. [0] = https://github.com/wal-g/wal-g/blob/8b9b3ca06efb44be4724208dc6f6d11836bd34= d9/internal/databases/postgres/queryRunner.go#L243=