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 1gsrEm-0000Ll-3C for pgsql-general@arkaria.postgresql.org; Sun, 10 Feb 2019 15:41:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gsrEi-0005Bk-3a for pgsql-general@arkaria.postgresql.org; Sun, 10 Feb 2019 15:41:40 +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 1gsrEh-0005Bc-Rr for pgsql-general@lists.postgresql.org; Sun, 10 Feb 2019 15:41:39 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gsrEa-0000CJ-9m for pgsql-general@postgresql.org; Sun, 10 Feb 2019 15:41:38 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x1AFf8cj017144; Sun, 10 Feb 2019 10:41:09 -0500 From: Tom Lane To: Hannes Erven cc: pgsql-general Subject: Re: Unused files in the database directory after crashed VACUUM FULL In-reply-to: References: Comments: In-reply-to Hannes Erven message dated "Sun, 10 Feb 2019 09:19:30 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17142.1549813268.1@sss.pgh.pa.us> Date: Sun, 10 Feb 2019 10:41:08 -0500 Message-ID: <17143.1549813268@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hannes Erven writes: > I've just had a "VACUUM FULL " crash due to 100% disk usage. > Clearly my fault, I was expecting the new table to be small enough. What do you mean by "crash" exactly? A normal transactional failure should've cleaned up orphaned files. I suppose if the kernel decided to kill -9 the vacuum process, that wouldn't happen --- but that's not the usual response to out-of-disk-space. > After freeing up space, restarting the cluster and issuing another > VACCUM FULL, I noticed that the cluster was way bigger that it should be. > In the base// folder, there was a large number of files with one > certain number that pg_filenode_relation() could not turn into a > relation. As that number was just a bit smaller that the > pg_relation_filepath() of the table I was working on, I guess these were > the remains of the failed VACUUM FULL operation? > I removed those files and a VACCUM ANALYZE of the whole database went fine. > So... is this the expected behaviour? Is there a safe procedure how to > check/clean up "unnecessary" files in the cluster directory? You just described it --- verify with pg_filenode_relation that the file doesn't correspond to any pg_class entry, then manually delete. (There is a crash-recovery phase that does something similar, but I think it's only designed to clean up temporary files.) regards, tom lane