Re: Postmaster holding unlinked files for pg_largeobject table

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Postmaster holding unlinked files for pg_largeobject table
Дата
Msg-id 15071.1307463994@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Postmaster holding unlinked files for pg_largeobject table  (Alvaro Herrera <alvherre@commandprompt.com>)
Ответы Re: Postmaster holding unlinked files for pg_largeobject table  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-hackers
Alvaro Herrera <alvherre@commandprompt.com> writes:
> Excerpts from Tom Lane's message of lun jun 06 12:49:46 -0400 2011:
>> Hmm, there's already a mechanism for closing "temp" FDs at the end of a
>> query ... maybe blind writes could use temp-like FDs?

> I don't think it can be made to work exactly like that.  If I understand
> correctly, the code involved here is the FlushBuffer() call that happens
> during BufferAlloc(), and what we have at that point is a SMgrRelation;
> we're several levels removed from actually being able to set the
> FD_XACT_TEMPORARY flag which is what I think you're thinking of.

It's not *that* many levels: in fact, I think md.c is the only level
that would just have to pass it through without doing anything useful.
I think that working from there is a saner and more efficient approach
than what you're sketching.

If you want a concrete design sketch, consider this:

1. Add a flag to the SMgrRelation struct that has the semantics of "all
files opened through this SMgrRelation should be marked as transient,
causing them to be automatically closed at end of xact".

2. *Any* normal smgropen() call would reset this flag (since it suggests
that we are accessing the relation because of SQL activity).  In the
single case where FlushBuffer() is called with reln == NULL, it would
set the flag after doing its local smgropen().

3. Then, modify md.c to pass the flag down to fd.c whenever opening an
FD file.  fd.c sets a bit in the resulting VFD.

4. Extend CleanupTempFiles to close the kernel FD (but not release the
VFD) when a VFD has the bit set.

I'm fairly sure that CleanupTempFiles is never called in the bgwriter,
so we don't even need any special hack to prevent the flag from becoming
set in the bgwriter.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: Vacuum, visibility maps and SKIP_PAGES_THRESHOLD
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: Re: [Pgbuildfarm-members] CREATE FUNCTION hang on test machine polecat on HEAD