]> granicus.if.org Git - postgresql/commitdiff
Generate pg_basebackup temporary slot name using backend pid
authorMagnus Hagander <magnus@hagander.net>
Wed, 31 May 2017 18:57:25 +0000 (20:57 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 31 May 2017 19:00:37 +0000 (21:00 +0200)
Using the client pid can easily be non-unique when used on different
hosts. Using the backend pid should be guaranteed unique, since the
temporary slot gets removed when the client disconnects so it will be
gone even if the pid is renewed.

Reported by Ludovic Vaugeois-Pepin

src/bin/pg_basebackup/pg_basebackup.c

index 432c282b5293e975c9a37519ea4d7df475a263cf..3d6fce2e348cee602b4ebe6a884cd3fdaeec26cf 100644 (file)
@@ -493,7 +493,7 @@ LogStreamerMain(logstreamer_param *param)
        stream.replication_slot = replication_slot;
        stream.temp_slot = param->temp_slot;
        if (stream.temp_slot && !stream.replication_slot)
-               stream.replication_slot = psprintf("pg_basebackup_%d", (int) getpid());
+               stream.replication_slot = psprintf("pg_basebackup_%d", (int) PQbackendPID(param->bgconn));
 
        if (format == 'p')
                stream.walmethod = CreateWalDirectoryMethod(param->xlog, 0, do_sync);