Re: BUG #5038: WAL file is pending deletion in pg_xlog folder, this interferes with WAL archiving.

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Luke Koops <luke(dot)koops(at)entrust(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5038: WAL file is pending deletion in pg_xlog folder, this interferes with WAL archiving.
Date: 2009-09-07 09:21:43
Message-ID: 4AA4D0A7.7040204@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Luke Koops wrote:
> The following bug has been logged online:
>
> Bug reference: 5038
> Logged by: Luke Koops
> Email address: luke(dot)koops(at)entrust(dot)com
> PostgreSQL version: 8.3.7
> Operating system: Windows 2003 Server Enterprise Edition
> Description: WAL file is pending deletion in pg_xlog folder, this
> interferes with WAL archiving.
> Details:
>
> On my system, one of the WAL files is pending deletion. The handle is being
> held by one of the postgres backend processes, but that is another potential
> bug.

Hmm. Under normal Unix filesystem semantics, that doesn't matter much
since the file can still be unlinked. It will still consume space, but
that's not a big issue. On Windows, however, the open handle keeps the
file locked, so it can't be deleted.

If I'm reading the code correctly, when a backend opens a WAL file for
writing to it, it stays open until the backend needs to write to another
WAL file. If the backend only writes once to a file, and then doesn't
create WAL records anymore (= executes read-only queries only), the file
is kept open indefinitely.

Perhaps we should try to close the old WAL file sooner. It's easy to
check if the current open log segment is old and close it if so, but I'm
not sure what the check should be hooked into.

> At first, the unlink worked, and the .ready and .done files were deleted.
> But the WAL file still shows up in the pg_xlog directory listing.

If the file didn't go away, it seems like the unlink didn't work. We
don't check the return code in RemoveOldXlogFiles(); I suspect that
we're getting EBUSY in that scenario. We should check for that if we're
going to delete the .ready and .done files. Patch attached, but I
haven't tested it. I don't have Windows environment at hand, but I'll
try to find one..

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
windows-unlink-can-fail-1.patch text/x-diff 638 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Stehule 2009-09-07 13:47:19 Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction
Previous Message Tomasz Karlik 2009-09-07 06:28:45 Odp: Re: BUG #5035: cast 'text' to 'name' doesnt work in plpgsqlfunction