File tree 3 files changed +20
-5
lines changed
3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -376,10 +376,12 @@ SyncRepReleaseWaiters(void)
376
376
/*
377
377
* If this WALSender is serving a standby that is not on the list of
378
378
* potential standbys then we have nothing to do. If we are still starting
379
- * up or still running base backup, then leave quickly also.
379
+ * up, still running base backup or the current flush position is still
380
+ * invalid, then leave quickly also.
380
381
*/
381
382
if (MyWalSnd -> sync_standby_priority == 0 ||
382
- MyWalSnd -> state < WALSNDSTATE_STREAMING )
383
+ MyWalSnd -> state < WALSNDSTATE_STREAMING ||
384
+ XLogRecPtrIsInvalid (MyWalSnd -> flush ))
383
385
return ;
384
386
385
387
/*
@@ -399,7 +401,8 @@ SyncRepReleaseWaiters(void)
399
401
walsnd -> state == WALSNDSTATE_STREAMING &&
400
402
walsnd -> sync_standby_priority > 0 &&
401
403
(priority == 0 ||
402
- priority > walsnd -> sync_standby_priority ))
404
+ priority > walsnd -> sync_standby_priority ) &&
405
+ !XLogRecPtrIsInvalid (walsnd -> flush ))
403
406
{
404
407
priority = walsnd -> sync_standby_priority ;
405
408
syncWalSnd = walsnd ;
Original file line number Diff line number Diff line change @@ -281,6 +281,11 @@ WalReceiverMain(void)
281
281
walrcv_connect (conninfo , startpoint );
282
282
DisableWalRcvImmediateExit ();
283
283
284
+ /* Initialize LogstreamResult, reply_message and feedback_message */
285
+ LogstreamResult .Write = LogstreamResult .Flush = GetXLogReplayRecPtr (NULL );
286
+ MemSet (& reply_message , 0 , sizeof (reply_message ));
287
+ MemSet (& feedback_message , 0 , sizeof (feedback_message ));
288
+
284
289
/* Loop until end-of-streaming or error */
285
290
for (;;)
286
291
{
Original file line number Diff line number Diff line change @@ -1510,12 +1510,19 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
1510
1510
1511
1511
if (walsnd -> pid != 0 )
1512
1512
{
1513
- sync_priority [i ] = walsnd -> sync_standby_priority ;
1513
+ /*
1514
+ * Treat a standby such as a pg_basebackup background process
1515
+ * which always returns an invalid flush location, as an
1516
+ * asynchronous standby.
1517
+ */
1518
+ sync_priority [i ] = XLogRecPtrIsInvalid (walsnd -> flush ) ?
1519
+ 0 : walsnd -> sync_standby_priority ;
1514
1520
1515
1521
if (walsnd -> state == WALSNDSTATE_STREAMING &&
1516
1522
walsnd -> sync_standby_priority > 0 &&
1517
1523
(priority == 0 ||
1518
- priority > walsnd -> sync_standby_priority ))
1524
+ priority > walsnd -> sync_standby_priority ) &&
1525
+ !XLogRecPtrIsInvalid (walsnd -> flush ))
1519
1526
{
1520
1527
priority = walsnd -> sync_standby_priority ;
1521
1528
sync_standby = i ;
You can’t perform that action at this time.
0 commit comments