Re: [PATCH] Atomic pgrename on Windows

Поиск
Список
Период
Сортировка
От Magnus Hagander
Тема Re: [PATCH] Atomic pgrename on Windows
Дата
Msg-id CABUevEz0Qyc-buFLKO7QdKXjfEAES_ddE_KHvbHkWJW=sX+n5A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Atomic pgrename on Windows  (Michael Paquier <michael.paquier@gmail.com>)
Ответы Re: Re: [PATCH] Atomic pgrename on Windows
Re: [PATCH] Atomic pgrename on Windows
Список pgsql-hackers


On Tue, Nov 28, 2017 at 2:47 AM, Michael Paquier <michael.paquier@gmail.com> wrote:
On Mon, Nov 27, 2017 at 3:28 PM, Alexander Korotkov
<a.korotkov@postgrespro.ru> wrote:
> Attached patch atomic-pgrename-windows-1.patch fixes this problem.  It
> appears to be possible to atomically replace file on Windows – ReplaceFile()
> does that.  ReplaceFiles() requires target file to exist, this is why we
> still need to call MoveFileEx() when it doesn't exist.

Do you think that it could be safer to unlink the target file first
with pgunlink()? This way you make sure that the target file is
removed and not locked. This change makes me worrying about the
introduction of more race conditions.

Unlinking it first seems dangerous, as pointed out by Andres.

What about first trying ReplaceFile() and then if it fails with "target doesn't exist", then call MoveFileEx().

Or the other way around -- try MoveFileEx() first since that seems to work most of the time today (if it mostly broke we'd be in trouble already), and if it fails with a sharing violation, try ReplaceFile()? And perhaps end up doing it something similar to what we do with shared memory which is just to loop over it and try  each a couple of time, before giving up and failing? 

--

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

Предыдущее
От: Marina Polyakova
Дата:
Сообщение: Re: master make check fails on Solaris 10
Следующее
От: Marina Polyakova
Дата:
Сообщение: Re: WIP Patch: Precalculate stable functions, infrastructure v1