Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 504c717

Browse files
committed
Fix bug in handling of connections that pg_receivexlog creates.
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
1 parent 5c38a1d commit 504c717

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/bin/pg_basebackup/pg_receivexlog.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ StreamLog(void)
293293
/*
294294
* Connect in replication mode to the server
295295
*/
296-
conn = GetConnection();
296+
if (conn == NULL)
297+
conn = GetConnection();
297298
if (!conn)
298299
/* Error message already written in GetConnection() */
299300
return;
@@ -345,6 +346,7 @@ StreamLog(void)
345346
fsync_interval);
346347

347348
PQfinish(conn);
349+
conn = NULL;
348350
}
349351

350352
/*
@@ -591,6 +593,11 @@ main(int argc, char **argv)
591593
disconnect_and_exit(1);
592594
}
593595

596+
/*
597+
* Don't close the connection here so that subsequent StreamLog()
598+
* can reuse it.
599+
*/
600+
594601
while (true)
595602
{
596603
StreamLog();

0 commit comments

Comments
 (0)