[pgpool-committers: 776] pgpool: Fix connecting to backend problem introduced in 3.2 due to usin
ishii at postgresql.org
Wed Jan 23 10:49:22 JST 2013
Fix connecting to backend problem introduced in 3.2 due to using
non-blocking socket reported in bug #46 and [pgpool-general: 1218]
The problem reported in [pgpool-general: 1218] was that the function
treats EISCONN of connect(2) as an error (error message is "Socket is
already connected"). We should treat this as normal and it has already
been fixed in master and 3.2-stable in commit
in December 5, 2012.
However this was not enough fix for #46. Despite the errors like
"Connection timed out", actually connection has been established:
> Nov 22 11:55:22 fantomas1 pgpool: connect_inet_domain_socket: connect() failed: Connection timed out
> Nov 22 11:55:22 fantomas1 pgpool: connection to fantomas4.prod.extelia.fr(5432) failed
> Nov 22 11:55:22 fantomas1 pgpool: new_connection: create_cp() failed
> Nov 22 11:55:22 fantomas1 pgpool: degenerate_backend_set: 1 fail over request from pid 30351
> A tcpdump from the same period shows that the connection has been established.
To solve the problem we should use select(2) to wait for connection
establishing when connect(2) reports EINPROGRESS or EALREADY, instead
of doing a retry tight loop. If those errors were reported, we issue
select(2) expecting read or write for the socket is set. The strange
part of the technique is, if both read and write were set, it
indicates *either* success or error. See the code magic and comment.
Back patch to 3.2-stable.
pool_connection_pool.c | 84 ++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 78 insertions(+), 6 deletions(-)
More information about the pgpool-committers