timeout of pg_receivexlog --status-interval

From: Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: timeout of pg_receivexlog --status-interval
Date: 2014-07-10 14:10:38
Message-ID: CAD21AoCEo27Ck1i7jrUnZ2cODOt5WtX=fDf=72OizUrDa0KQPg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

At 1047 line of receivelog.c:CopyStreamPoll(), we set NULL to
timeoutptr variable.
if the value of timeoutprt is set NULL then the process will wait
until can read socket using by select() function as following.

if (timeout_ms < 0)
timeoutptr = NULL;
else
{
timeout.tv_sec = timeout_ms / 1000L;
timeout.tv_usec = (timeout_ms % 1000L) * 1000L;
timeoutptr = &timeout;
}

ret = select(PQsocket(conn) + 1, &input_mask, NULL, NULL, timeoutptr);

But the 1047 line of receivelog.c is never executed because the value
of timeout_ms is NOT allowed less than 0 at CopyStreamReceive which is
only one function calls CopyStreamPoll().
The currently code, if we specify -s to 0 then CopyStreamPoll()
function is never called.
And the pg_receivexlog will be execute PQgetCopyData() and failed, in
succession.

I think that it is contradiction, and should execute select() function
with NULL of fourth argument.
the attached patch allows to execute select() with NULL, i.g.,
pg_receivexlog.c will wait until can read socket without timeout, if
-s is specified to 0.

Regards,
-------
Sawada Masahiko

Attachment Content-Type Size
receivexlog-timout.patch application/octet-stream 882 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message MauMau 2014-07-10 14:25:57 Re: Proposing pg_hibernate
Previous Message Sawada Masahiko 2014-07-10 13:53:33 Re: add line number as prompt option to psql