Should we nonblocking open FIFO files in COPY? - Mailing list pgsql-hackers

From Adam Lee
Subject Should we nonblocking open FIFO files in COPY?
Date
Msg-id 20171222061036.GH1335@rmbp
Whole thread Raw
Responses Re: Should we nonblocking open FIFO files in COPY?
List pgsql-hackers
Hi,

I have an issue that COPY from a FIFO, which has no writers, could not be
canceled, because COPY invokes AllocateFile() -> fopen() -> blocking open().

```
[postgres@s1 ~]$ mkfifo /tmp/test0
[postgres@s1 ~]$ /usr/local/pgsql/bin/psql test
psql (11devel)
Type "help" for help.

test=# create table test(t text);
CREATE TABLE
test=# copy test from '/tmp/test0';
^CCancel request sent
^CCancel request sent
^CCancel request sent
^CCancel request sent
^CCancel request sent
^CCancel request sent
...
```

Should we nonblocking open FIFO files?

And a following question if we nonblocking open them, say there is a
FIFO file, no one will write into it, and a utility calls `COPY FROM`
it, should we just return `COPY 0` or wait writers? If we wait, then
users have to interrupt or write an EOF into the FIFO after a timeout,
I see some utilities do that, gptransfer for instance, just seems not
right.

My plan is to write a new function which nonblocking opens FIFOs just
for COPY, and not waits writers, what do you think?

-- 
Adam Lee


pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: reassure me that it's good to copy pg_control last in a basebackup
Next
From: Feike Steenbergen
Date:
Subject: Re: Fix permissions check on pg_stat_get_wal_senders