Re: VACUUM FULL, power failure results in unrecoverable space - Mailing list pgsql-general

From Guillaume Lelarge
Subject Re: VACUUM FULL, power failure results in unrecoverable space
Date
Msg-id CAECtzeVZ1C_CmK_AxMV1B5VdhKRoH3DV7zu9Omr0yCijHQXa+g@mail.gmail.com
Whole thread Raw
In response to VACUUM FULL, power failure results in unrecoverable space  ("Pierre Barre" <pierre@barre.sh>)
List pgsql-general
Hi,


Le mar. 3 déc. 2024, 01:02, Pierre Barre <pierre@barre.sh> a écrit :
Hello,

I encountered an issue while attempting to reclaim space from a heavily bloated table:

Initial analysis using https://github.com/ioguix/pgsql-bloat-estimation/blob/master/table/table_bloat.sql indicated approximately 600GB of bloat in the table.

I initiated a VACUUM FULL operation to reclaim this space, but during execution, the server experienced a power failure.


After server recovery:

1. The database came back online successfully
2. The space used by the in-progress table reconstruction was not freed

Because doesn't know it's here.

3. The newly wasted space (bloat + partial VACUUM FULL) is not shown using the above query, only the initial bloat.

Because it's not the same kind of bloat. Vacuum full builds another set of files for the table, and these files aren't yet connected to the table, since vacuum full didn't finish. You've got some orphaned files you'll have to delete. 



Is there a way to reclaim this space without resorting to a full pg_dump and pg_restore cycle? 

You can dump and restore (which will drop all bloat of this database), but will probably take too long to finish. You can also see pg_orphaned to know which files to delete (https://github.com/bdrouvot/pg_orphaned).

Regards.


-- 
Guillaume.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Help in vetting my steps for Postgres DB upgrade from Ver 13.X to ver 15.X
Next
From: "Tefft, Michael J"
Date:
Subject: Autovacuum and visibility maps