Hi all,
During testing recovery, I realized that it's possible that a relation
file is orphaned (probably) forever if postgres crashes during
executing a transaction that creates a new relation and loads data.
After postgres crashing, the relation is recovered during crash
recovery and the transaction is regards as aborted, but that relation
file exists in database cluster. There seems no way for postgres to
know that that relation is now garbage and can be deleted. The entry
of that relation in pg_class exists but it is never detected even by
autovacuum because autovacuum's snapshot doesn't include that. In
addition, that relfilenode number is never be reused because the file
already exists. Therefore I think that such orphaned relation file is
left forever. The orphaned relation can be large if we are loading
large data or creating a large materialized view.
Is this a bug? Has this ever been discussed?
Regards,
--
Masahiko Sawada http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services