Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rfHxB-00Ghl6-Gx for pgsql-general@arkaria.postgresql.org; Wed, 28 Feb 2024 11:18:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rfHxA-009QOd-3k for pgsql-general@arkaria.postgresql.org; Wed, 28 Feb 2024 11:18:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rfHvc-009QEY-LN for pgsql-general@lists.postgresql.org; Wed, 28 Feb 2024 11:16:49 +0000 Received: from mout.gmx.net ([212.227.15.18]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rfHvZ-001kNU-Qf for pgsql-general@lists.postgresql.org; Wed, 28 Feb 2024 11:16:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1709119004; x=1709723804; i=jimis@gmx.net; bh=Zg7jCzPaVsSomG8s23BlIE5fFRqHk0T3qQvLQ9sDLmU=; h=X-UI-Sender-Class:Date:From:To:Subject; b=hzhK+YjtCvyQna2doJcS8y2ULV2zYfaAJxpvyst2+mSPkFZWkTVIk/L+8ZiKr8pV HdFG9vfNA/cQ/h7Ll2kV6YvCeKR4chSmN5QXQvtKjSEY7l4dh0aC0PKl2oGIwuA6T E6CpXuerftFGxnWxuDHF1cxeNUBvV7BvAhYXQIDS1Dlc4YAZjQgH8jbM2x6WhKdtp hjjRusJXyB08c7ZuP+1MU5AjJ6aU984DTG/lXjZq9PulcjwlLBj8hDcFrBi+5TL8n zGrm7XRDIoX/wz9fPcXqe+GmzL82/kHx/ZcQs+fyfFrILcU/5ImR1TB9NhXYqd2ez xb3XVAXQ0Wj0H3HYOQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.0.96] ([178.232.0.21]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N2mBa-1quEkq093E-0132Vf for ; Wed, 28 Feb 2024 12:16:44 +0100 Date: Wed, 28 Feb 2024 12:16:43 +0100 (CET) From: Dimitrios Apostolou To: pgsql-general@lists.postgresql.org Subject: Orphan files filling root partition after crash Message-ID: MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Provags-ID: V03:K1:bIdluX+V9kPUHfO4pQJkXr3KlY/baFolIBOYTYfKYIA0S0xSVyO OscY0wd8rkdEiBU6ayz2vwIEyAx9fjFIW5TvqBHhIsHr7Fi4oWesEDQPCaJPnVE+B0m2sL2 vE+3XAL9qfy9qRzsaZmlEh5pwk3/nlOOnQprwlYF2k3hifTSVFYIbrJ9BLy2fZNczOQrDjk iYMuFnubSvQaoVaDtIuiA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:PQkfP0cdIY0=;OjLodXSqeL6x8RaSCcsHVqrg/9e M/QeOJwlnt6ybpujRA4NZ5AsaZUvQDA8DLlHj2+EYZeav5otKdUFaxqMLZ89CX6eiTY1ZLkLw O9hF6iTo0QmcPWOIzS3uB6ZEuEIHb7iwfCMfjttfshMg6NiPjSAhYnfZpEEJJpfGpQgNakkfo a2w/S99hRqv2X3NJkzVKQB8OQAwHF9S2xs514O1USligjlBPkrZ0oNaCbgL0vg+WKaUkWAIY8 msgnY+hWkFjqeV5KdoZRDpPRR/scfK852QKE3+yMHCuTtRmwNAQARIHTpcIOeIjLHjLLM/3Rp g+lukkfVM46LkfcLtOyHxDntonhQdf3xzzgquDT1MWDyxC4ZNSu0ynTHEDFd5QkxkanY3Vlde kB/ayYAeoo1PQ2v3fJWvIsN3Fm5kznElIZ1R8UZVnmpPRVSI3xM1ggljLrjLxZVcS5sbpMSw9 uLpkWdHxXq9cHILjax5Qk/oiqOJO6MhBhmIM2k5ZbPAPY/aHMTlGUq0OnaNm0La18b17NwAby DPoA/Ah7DS+THXGJ4tCi7nQflRQxo45ELvYdqZ8nyTMDavfsEp+k9dbL/5/WwEB7+dMoBeCzP uK2LD9M6TZX3RffvbtYC6EsFGrbAD/eKEmX7MlmbuRpddTHcVpFfHvyG6flmSmEW7wTMA/eo7 LUduNemnWUjSHC56D++ae/io5TR8hF18gu6zaNshoUsQVgyimz3hRlHE18Ilr6gJoMqI1teZf 5pM/wkXZ+QLow60ASuDYj6V67QSjfHIaQXHZQ7vcdNfhZo5rAqXbP4SHyGaakQTJCuKWT8Lq1 mMisOVlkJg97fLtkQD8k1KHWpQhc6MZAuqZIw0Jx+6LGs= Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello list, yesterday I was doing: ALTER TABLE x ADD UNIQUE ... , ADD PRIMARY KEY ...; The table is almost a billion rows long but lies in its own TABLESPACE that has plenty of space. But apparently the ALTER TABLE command is writing a lot to the default tablespace (not the temp_tablespace, that is already moved to a different partition). That quickly filled up the 50GB free space in my root partition: 20:18:04.222 UTC [94144] PANIC: could not write to file "pg_wal/xlogtemp.= 94144": No space left on device [...] 20:19:11.578 UTC [94140] LOG: WAL writer process (PID 94144) was terminat= ed by signal 6: Aborted 20:19:11.578 UTC [94140] LOG: terminating any other active server process= es After postgresql crashed and restarted, the disk space in the root partition was still not freed! I believe this is because of "orphaned files" as discussed in mailing list thread [1]. [1] https://www.postgresql.org/message-id/CAN-RpxDBA7HbTsJPq4t4VznmRFJkssP= 2SNEMuG%3DoNJ%2B%3DsxLQew%40mail.gmail.com I ended up doing some risky actions to remediate the problem: Find the filenames that have no identically named "oid" in pg_class, and delete (move to backup) the biggest ones while the database is stopped. Fortunately the database started up fine after that! So what is the moral of the story? How to guard against this? Why did the database write so much to the default tablespace, even when both the table and the temp tablespace are elsewhere? Also should one always keep the default tablespace away from the wal partition? (I guess it would have helped to avoid the crash, but the ALTER TABLE command would have still run out of space, so I'm not sure if the orphan files would have been avoided)? Needless to say, I would have hoped the database cleaned-up after itself even after an uncontrolled crash, or that it provided some tools for the job. (I tried VACUUM FULL on the table, but the orphaned files did not go away). My postgresql version is 16.2 installed on Ubuntu. Thank you, Dimitris