Cleaning up unreferenced table files

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: pgsql-patches(at)postgresql(dot)org
Subject: Cleaning up unreferenced table files
Date: 2005-03-05 22:35:57
Message-ID: Pine.OSF.4.61.0503060004140.143050@kosh.hut.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Here's a patch for the TODO item "Remove unreferenced table files created by transactions
that were in-progress when the server terminated abruptly."

It adds a new function, CleanupStaleRelFiles, that scans through the data
directory and removes all table files that are not mentioned in pg_class
of the corresponding database. CleanupStaleRelFiles is called after WAL
recovery.

Actually, the patch doesn't currently delete the files, just issues a
warning. Testing is easier if the files don't keep getting deleted :).

The patch also adds a GetTablespacePath function similar to
GetDatabasePath that constructs the path to a tablespace symbolic link.
commands/tablespace.c is modified to use it, in addition to the new
CleanupStaleRelFiles function.

- Heikki

Attachment Content-Type Size
cleanup_stales_20050305.diff text/plain 10.2 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-03-05 23:36:25 Re: Cleaning up unreferenced table files
Previous Message Heikki Linnakangas 2005-03-05 22:17:05 Harmless space allocation typo