Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jIgkA-00020t-8k for pgsql-general@arkaria.postgresql.org; Sun, 29 Mar 2020 22:49:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jIgk8-0005B2-Uf for pgsql-general@arkaria.postgresql.org; Sun, 29 Mar 2020 22:49:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jIgk8-0005Au-Ms for pgsql-general@lists.postgresql.org; Sun, 29 Mar 2020 22:49:24 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jIgk2-0006oE-O8 for pgsql-general@postgresql.org; Sun, 29 Mar 2020 22:49:22 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 7F6DC22A6; Mon, 30 Mar 2020 00:49:13 +0200 (CEST) Date: Mon, 30 Mar 2020 00:49:13 +0200 From: "Peter J. Holzer" To: pgsql-general@postgresql.org Subject: Idle sessions keep deleted files open Message-ID: <20200329224913.GA11265@hjp.at> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="HlL+5n6rz5pIUxbD" Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I noticed this with PostgreSQL 11.7 on Linux: I did a =ABvacuum full=BB on a table which had become quite bloated (size before the vacuum: 392 GB, after: 291 GB). I expected the disk usage to increase as the new table was written and then drop sharply after the vacuum was finished. However, that didn't happen. While usage increased by about 300 GB during the vacuum, it stayed the same afterwards (as reported by =ABdf=BB). However, =ABdu=BB reported about 400 GB less than =ABdf=BB. So apparently, = files had been unlinked but were still in use by some process. =ABlsof=BB confirmed this: There were some idle sessions which were keeping the files open. As soon as I got those sessions to execute some request, they closed the files, causing the disk space to be freed. I think I noticed that before when dropping tables, but didn't draw the right conclusion at the time. So, if you are reorganizing large tables, keep an eye on idle sessions - they may keep deleted files around for quite some time. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --HlL+5n6rz5pIUxbD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl6BJeQACgkQ8g5IURL+ KF2OVQ//SaREWBmNIFZVsPbm4O6agiGuFWLbO1+4O+z2f5UTCaHp6yQ/82xBCyoI 2O33B44dF4zIpzhsFQH/hhclSOqnM8tSayVq6vG12tzIQ81U6a8K7D6WvCLHYby0 K2wFxgjsPhjnALJXuvpNveP8/qqSrfmsJ080GvQMCs8E5UZ0GkriBSG3cZUSn8kr JjTnyi1W+cNjlVvo2HDjlddbaVf+53v2zUk8eSjQdDjovDcafhNieYnIgZG3di73 Obmains0JKQ6KxyhsIzCGIudZFWDKUIUd8oJwIc0geEdZz6C6SrvUBk/CHhhQNdC 2GGR94fqDJV1jvNUQtBgsS6B9XsSyHTsbhewRXj1+qKN6eBB5h+wpyF2Ee+1VOLh mb+qIPzbWx0HpUiqVTcLbue5sTQ2+5+dzo4tgZdVaNSxK72neHCfSza5daFCKs/o e5q0Uh5VRv/rJPxU/7lveXIptvTMSNaZ/9uGOtul9vD9IfgHa4LJyUkoupDpJqZ5 78uN4pZPIOsl5KKMvMMOk30OeIMo1YsUa9zY14rym8xam1hjdRQcVjra8+qGOhvw XV/DTkubd3c23zCokXmCT3Ka6EFjpLRgyFFXRoK4/DgCH8Y+VjZiQvXukiJI8/vU t0EfkuW0S04uaYIwD/EETWFIHlPZn7jlIa/LXGsG2VKgZe3HkUk= =rQcQ -----END PGP SIGNATURE----- --HlL+5n6rz5pIUxbD--