Re: [Patch] Check file type before calling AllocateFile() for filesout of pg data directory to avoid potential issues (e.g. hang). - Mailing list pgsql-hackers
From
Paul Guo
Subject
Re: [Patch] Check file type before calling AllocateFile() for filesout of pg data directory to avoid potential issues (e.g. hang).
On Wed, Apr 24, 2019 at 12:49 PM Andres Freund <andres@anarazel.de> wrote:
Hi,
On 2019-04-24 12:46:15 +0800, Paul Guo wrote: > This is, in theory, not a 100% bug, but it is probably not unusual to see > conflicts of files between postgresql sqls and other applications on the > same node so I think the fix is needed. I checked all code that calls > AllocateFile() and wrote a simple patch to do sanity check (if the file > exists it must be a regular file) for those files which are probably out of > the postgres data directories which we probably want to ignore. This is > actually not a perfect fix since it is not atomic (check and open), but it > should fix most of the scenarios. To be perfect, we might want to refactor > AllocateFile() to allow atomic check&create using either 'x' in fopen() > or O_EXCL in open(), also it seems that we might not want to create temp > file for AllocateFile() with fixed filenames. This is beyond of this patch > of course.
This seems like a bad idea to me. IMO we want to support using a pipe etc here. If the admin creates a fifo like this without attaching a program it seems like it's their fault.
Oh, I never know this application scenario before. So yes, for this, we need to keep the current code logic in copy code.
From:
Andres Freund Date: Subject:
Re: [Patch] Check file type before calling AllocateFile() for filesout of pg data directory to avoid potential issues (e.g. hang).