bgwriter leaks resources after errors

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: bgwriter leaks resources after errors
Date: 2005-12-08 17:50:35
Message-ID: 12214.1134064235@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I think that bug #2099
http://archives.postgresql.org/pgsql-bugs/2005-12/msg00075.php
is probably explained by the observation that the bgwriter fails to call
AtEOXact_Files() after an error; therefore, if it gets an error while
holding an open DIR pointer, the DIR will never get closed. (There are
calls to AllocateDir in the checkpoint code path, eg SimpleLruTruncate.)

But while looking at this I realized we have worse problems: there's
no mechanism for releasing buffer pins after an error in the bgwriter.
So, for example, a write error on a dirty buffer will cause bgwriter
to permanently leak a buffer pin. Even if the write problem is later
rectified, the buffer will remain pinned indefinitely. Quite aside
from the consequences of resource-leakage, this could make it impossible
to complete subsequent VACUUMs on the affected relation. That raises it
to a "must fix" in my mind. The bug exists in 8.0 and later.

The cleanest solution seems to be to make the bgwriter create and use a
ResourceOwner, and probably get rid of the special hack in resowner.c
that allows CurrentResourceOwner to be NULL.

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-12-08 18:07:10 Re: generalizing the planner knobs
Previous Message Rod Taylor 2005-12-08 17:49:48 Re: [PATCHES] Inherited Constraints