Orphaned relation files after crash recovery - Mailing list pgsql-hackers

From Masahiko Sawada
Subject Orphaned relation files after crash recovery
Date
Msg-id CA+fd4k7KHw0E5t9_4LFmsiFYL7SQrtwK312TQQ8q0gUDmy3jkw@mail.gmail.com
Whole thread Raw
Responses Re: Orphaned relation files after crash recovery
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Wait event that should be reported while waiting for WALarchiving to finish
Next
From: Thomas Munro
Date:
Subject: Re: Orphaned relation files after crash recovery