Re: Bug report - pg_upgrade tool seems to have a race condition when trying to delete a pg_wal file

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Waka Ranai <wakadotranai(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Bug report - pg_upgrade tool seems to have a race condition when trying to delete a pg_wal file
Date: 2024-05-29 07:51:08
Message-ID: 97f7b82147f7b84d0ce3e2a8e6cff3367faedc2e.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, 2024-05-28 at 16:14 +0200, Waka Ranai wrote:
> We tested on the aforementioned computer after adding an exception on the pg_wal
> folder for the Microsoft default antivirus with
> Add-MpPreference -ExclusionPath "C:\Program Files\PostgreSQL\15\data\pg_wal"
> but we still faced the same issue, I included the pg_upgrade logs

Thanks. I see

command: "C:/Program Files/PostgreSQL/15/bin/pg_resetwal" -f -u 536 "C:/Program Files/PostgreSQL/15/data" >> "C:/Program Files/PostgreSQL/15/data/pg_upgrade_output.d/202405>
Write-ahead log reset

command: "C:/Program Files/PostgreSQL/15/bin/pg_resetwal" -f -x 3466214 "C:/Program Files/PostgreSQL/15/data" >> "C:/Program Files/PostgreSQL/15/data/pg_upgrade_output.d/20>
pg_resetwal: error: could not delete file "pg_wal/000000010000000000000001": No such file or directory

So it is failing in KillExistingXLOG(): readdir() finds the file,
but by the time unlink() is executed, the file is already gone.
The file in question is the WAL segment written by WriteEmptyXLOG() in the
previous "pg_resetwal" execution.

But the previous "pg_resetwal" has exited by the time the next one is started,
so it should not be at fault.

I found this similar thread:
https://postgr.es/m/20090910094211.166C5753FB7%40cvs.postgresql.org
The symptoms are the same.

I wonder if something like commit 4e2d5efc6a45b1f9f96df42629f6d1c7740e657e
would be useful here too. But it cannot be a PostgreSQL process that is
holding the file open - the creating process has already exited, and no
other PostgreSQL process would read the file.

So the fact remains that there is something *outside of PostgreSQL* that
opens newly created files. You say you disabled the virus scanner, but can
you think of any other software on your system that would do that?
Perhaps you can try disabling the virus scanner completely and check if
that gets rid of the problem.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-05-29 09:05:25 BUG #18486: Is there something wrong with the calculation in ReorderBufferChangeSize()?
Previous Message Haifang Wang (Centific Technologies Inc) 2024-05-28 18:21:18 RE: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607