Re: [COMMITTERS] pgsql: Use asynchronous connect API in libpqwalreceiver

Peter Eisentraut <peter.eisentraut@2ndquadrant.com>

From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Petr Jelinek <petr.jelinek@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgreSQL.org, Andrew Dunstan <andrew@dunslane.net>
Date: 2017-03-06T14:38:49Z
Lists: pgsql-hackers
On 3/4/17 01:45, Petr Jelinek wrote:
> I can see one difference though (I didn't see this code before) and that
> is, the connectDBComplete starts with waiting for socket to become
> writable and only then calls PQconnectPoll, while my patch starts with
> PQconnectPoll call. And I see following comment in connectDBstart
>> 	/*
>> 	 * The code for processing CONNECTION_NEEDED state is in PQconnectPoll(),
>> 	 * so that it can easily be re-executed if needed again during the
>> 	 * asynchronous startup process.  However, we must run it once here,
>> 	 * because callers expect a success return from this routine to mean that
>> 	 * we are in PGRES_POLLING_WRITING connection state.
>> 	 */

Yes, the libpq documentation also says that.

> If that's the case, the attached should fix it, but I have no way of
> testing it on windows, I can only say that it still works on my machine
> so at least it hopefully does not make things worse.

Committed that.  Let's see how it goes.

I rewrote the while loop as a for loop so that the control logic isn't
spread out over three screens.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Commits

  1. Fix WaitEventSetWait() to handle write-ready waits properly on Windows.

  2. Rewrite async-connection loop in libpqwalreceiver.c, once again.

  3. Use asynchronous connect API in libpqwalreceiver