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 1gP12N-0004hs-8v for pgsql-admin@arkaria.postgresql.org; Tue, 20 Nov 2018 08:05:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gP12L-0007v3-3T for pgsql-admin@arkaria.postgresql.org; Tue, 20 Nov 2018 08:05:33 +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 1gP12K-0007uZ-S0 for pgsql-admin@lists.postgresql.org; Tue, 20 Nov 2018 08:05:32 +0000 Received: from mo19.mail-out.ovh.net ([178.32.228.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gP129-0003DM-Qb for pgsql-admin@postgresql.org; Tue, 20 Nov 2018 08:05:29 +0000 Received: from EX2.emp.local (gw1.pro1.mail.ovh.net [79.137.0.65]) by mo19.mail-out.ovh.net (Postfix) with ESMTPS id DAA987618B; Tue, 20 Nov 2018 09:05:19 +0100 (CET) Received: from DAG4EX1.emp.local (172.16.2.7) by EX2.emp.local (172.16.2.2) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1531.3; Tue, 20 Nov 2018 09:05:18 +0100 Received: from [192.168.1.23] (86.248.124.200) by DAG4EX1.emp.local (172.16.2.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1531.3; Tue, 20 Nov 2018 09:05:18 +0100 Subject: Re: Can long-running VACUUM be interrupted? To: Andrey Zhidenkov , References: From: Adrien NAYRAT Message-ID: <039bd8a3-bae5-cdee-e310-b53112f2086f@anayrat.info> Date: Tue, 20 Nov 2018 09:05:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US-large Content-Transfer-Encoding: 7bit X-Originating-IP: [86.248.124.200] X-ClientProxiedBy: EX3.emp.local (172.16.2.3) To DAG4EX1.emp.local (172.16.2.7) X-Ovh-Tracer-Id: 13852790982073219591 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedruddtgedguddulecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/20/18 4:58 AM, Andrey Zhidenkov wrote: > I have long-running prevent wraparound VACUUM (it has been running for > 6 days at the moment). The question is: if I interrupt this process in > some way (restart database, for instance), will it start from the > beginning? On the one hand, it opens a new transaction at the > beginning (according to the source code), on the other hand it updates > some data on the disk (WAL?). It confuses me. Could someone please > explain me this? > - > With best regards, Andrey Zhidenkov > Hi Andrez, You could interrupt with pg_cancel_backend function, but autovacuum will restart after autovacuum_naptime delay (1min by default). If you are 9.6+, Postgres will be able to skip already frozen row on the table, but it will scan all indexes from the beginning. Why do you want to interrupt? This kind of vacuum is necessary to avoid wraparound: https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND Regards,