File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -379,10 +379,12 @@ SyncRepReleaseWaiters(void)
379
379
/*
380
380
* If this WALSender is serving a standby that is not on the list of
381
381
* potential standbys then we have nothing to do. If we are still starting
382
- * up or still running base backup, then leave quickly also.
382
+ * up, still running base backup or the current flush position is still
383
+ * invalid, then leave quickly also.
383
384
*/
384
385
if (MyWalSnd -> sync_standby_priority == 0 ||
385
- MyWalSnd -> state < WALSNDSTATE_STREAMING )
386
+ MyWalSnd -> state < WALSNDSTATE_STREAMING ||
387
+ XLogRecPtrIsInvalid (MyWalSnd -> flush ))
386
388
return ;
387
389
388
390
/*
@@ -402,7 +404,8 @@ SyncRepReleaseWaiters(void)
402
404
walsnd -> state == WALSNDSTATE_STREAMING &&
403
405
walsnd -> sync_standby_priority > 0 &&
404
406
(priority == 0 ||
405
- priority > walsnd -> sync_standby_priority ))
407
+ priority > walsnd -> sync_standby_priority ) &&
408
+ !XLogRecPtrIsInvalid (walsnd -> flush ))
406
409
{
407
410
priority = walsnd -> sync_standby_priority ;
408
411
syncWalSnd = walsnd ;
Original file line number Diff line number Diff line change @@ -276,6 +276,11 @@ WalReceiverMain(void)
276
276
walrcv_connect (conninfo , startpoint );
277
277
DisableWalRcvImmediateExit ();
278
278
279
+ /* Initialize LogstreamResult, reply_message and feedback_message */
280
+ LogstreamResult .Write = LogstreamResult .Flush = GetXLogReplayRecPtr ();
281
+ MemSet (& reply_message , 0 , sizeof (reply_message ));
282
+ MemSet (& feedback_message , 0 , sizeof (feedback_message ));
283
+
279
284
/* Loop until end-of-streaming or error */
280
285
for (;;)
281
286
{
Original file line number Diff line number Diff line change @@ -1443,12 +1443,19 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
1443
1443
1444
1444
if (walsnd -> pid != 0 )
1445
1445
{
1446
- sync_priority [i ] = walsnd -> sync_standby_priority ;
1446
+ /*
1447
+ * Treat a standby such as a pg_basebackup background process
1448
+ * which always returns an invalid flush location, as an
1449
+ * asynchronous standby.
1450
+ */
1451
+ sync_priority [i ] = XLogRecPtrIsInvalid (walsnd -> flush ) ?
1452
+ 0 : walsnd -> sync_standby_priority ;
1447
1453
1448
1454
if (walsnd -> state == WALSNDSTATE_STREAMING &&
1449
1455
walsnd -> sync_standby_priority > 0 &&
1450
1456
(priority == 0 ||
1451
- priority > walsnd -> sync_standby_priority ))
1457
+ priority > walsnd -> sync_standby_priority ) &&
1458
+ !XLogRecPtrIsInvalid (walsnd -> flush ))
1452
1459
{
1453
1460
priority = walsnd -> sync_standby_priority ;
1454
1461
sync_standby = i ;
You can’t perform that action at this time.
0 commit comments