Previously pg_receivexlog created new connection for WAL streaming
even though another connection which had been established to create
or delete the replication slot was being left. This caused the unused
connection to be left uselessly until pg_receivexlog exited.
This bug was introduced by the commit
d9f38c7.
This patch changes pg_receivexlog so that the connection for
the replication slot is reused for WAL streaming.
Andres Freund, slightly modified by me, reviewed by Michael Paquier
/*
* Connect in replication mode to the server
*/
- conn = GetConnection();
+ if (conn == NULL)
+ conn = GetConnection();
if (!conn)
/* Error message already written in GetConnection() */
return;
fsync_interval);
PQfinish(conn);
+ conn = NULL;
}
/*
disconnect_and_exit(1);
}
+ /*
+ * Don't close the connection here so that subsequent StreamLog()
+ * can reuse it.
+ */
+
while (true)
{
StreamLog();