From 4b9c048235ff5ea2d95cae26f008a9eb4c28af26 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Wed, 13 Nov 2019 12:25:41 +0100 Subject: [PATCH] Close socket properly before the next iteration This avoid the errors `[Errno 106] Transport endpoint is already connected` which are due to connections kept in TIME_WAIT state. We don't use socket.SO_REUSEADDR as it would make the first connection a special case compared to the following ones. --- scripts-available/CDB_FederatedServerDiagnostics.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts-available/CDB_FederatedServerDiagnostics.sql b/scripts-available/CDB_FederatedServerDiagnostics.sql index f33d22b..05aac38 100644 --- a/scripts-available/CDB_FederatedServerDiagnostics.sql +++ b/scripts-available/CDB_FederatedServerDiagnostics.sql @@ -161,6 +161,8 @@ AS $$ except (socket.timeout, OSError, socket.error), ex: plpy.warning('could not connect to server %s:%d, %s' % (host, port, str(ex))) n_errors += 1 + finally: + s.close() t_connect = (t_stop - t_start) * 1000.0 plpy.debug('TCP connection %s:%d time=%.2f ms' % (host, port, t_connect))