Re: [HACKERS] Orphaned files in base/[oid] - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Orphaned files in base/[oid]
Date
Msg-id 25537.1502803950@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] Orphaned files in base/[oid]  (Chris Travers <chris.travers@adjust.com>)
Responses Re: [HACKERS] Orphaned files in base/[oid]
List pgsql-hackers
Chris Travers <chris.travers@adjust.com> writes:
> I wonder about a different solution.  Would it be possible to special case
> vacuum to check for and remove (or just move to where they can be removed)
> files when vacuuming pg_class?  At the point we are vacuuming pg_class, we
> ought to be able to know that a relfilenode shouldn't be used anymore,
> right?

I don't think so.  It's not clear to me whether you have in mind "scan
pg_class, collect relfilenodes from all live tuples, then zap all files
not in that set" or "when removing a dead tuple, zap the relfilenode
it mentions".  But neither one works.  The first case has a race condition
against new pg_class entries.  As for the second, the existence of a dead
tuple bearing relfilenode N isn't evidence that some other live tuple
can't have relfilenode N.

Another problem for the second solution is that in the case you're worried
about (ie, PANIC due to out-of-WAL-space during relation's creating
transaction), there's no very good reason to expect that the relation's
pg_class tuple ever made it to disk at all.

A traditional low-tech answer to this has been to keep the WAL on a
separate volume from the main data store, so that it's protected from
out-of-space conditions in the main store and temp areas.  The space
needs for WAL proper are generally much more predictable than the main
store, so it's easier to keep the dedicated space from overflowing.
(Stalled replication/archiving processes can be hazardous to your
health in this scenario, though, if they prevent prompt recycling of
WAL files.)
        regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] [PATCH] pageinspect function to decode infomasks
Next
From: Robert Haas
Date:
Subject: Re: [HACKERS] shared memory based stat collector (was: Sharing recordtypmods between backends)