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 @@ -377,10 +377,12 @@ SyncRepReleaseWaiters(void)
377
377
/*
378
378
* If this WALSender is serving a standby that is not on the list of
379
379
* potential standbys then we have nothing to do. If we are still starting
380
- * up or still running base backup, then leave quickly also.
380
+ * up, still running base backup or the current flush position is still
381
+ * invalid, then leave quickly also.
381
382
*/
382
383
if (MyWalSnd -> sync_standby_priority == 0 ||
383
- MyWalSnd -> state < WALSNDSTATE_STREAMING )
384
+ MyWalSnd -> state < WALSNDSTATE_STREAMING ||
385
+ XLogRecPtrIsInvalid (MyWalSnd -> flush ))
384
386
return ;
385
387
386
388
/*
@@ -400,7 +402,8 @@ SyncRepReleaseWaiters(void)
400
402
walsnd -> state == WALSNDSTATE_STREAMING &&
401
403
walsnd -> sync_standby_priority > 0 &&
402
404
(priority == 0 ||
403
- priority > walsnd -> sync_standby_priority ))
405
+ priority > walsnd -> sync_standby_priority ) &&
406
+ !XLogRecPtrIsInvalid (walsnd -> flush ))
404
407
{
405
408
priority = walsnd -> sync_standby_priority ;
406
409
syncWalSnd = walsnd ;
Original file line number Diff line number Diff line change @@ -280,6 +280,11 @@ WalReceiverMain(void)
280
280
walrcv_connect (conninfo , startpoint );
281
281
DisableWalRcvImmediateExit ();
282
282
283
+ /* Initialize LogstreamResult, reply_message and feedback_message */
284
+ LogstreamResult .Write = LogstreamResult .Flush = GetXLogReplayRecPtr (NULL );
285
+ MemSet (& reply_message , 0 , sizeof (reply_message ));
286
+ MemSet (& feedback_message , 0 , sizeof (feedback_message ));
287
+
283
288
/* Loop until end-of-streaming or error */
284
289
for (;;)
285
290
{
Original file line number Diff line number Diff line change @@ -1530,12 +1530,19 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
1530
1530
1531
1531
if (walsnd -> pid != 0 )
1532
1532
{
1533
- sync_priority [i ] = walsnd -> sync_standby_priority ;
1533
+ /*
1534
+ * Treat a standby such as a pg_basebackup background process
1535
+ * which always returns an invalid flush location, as an
1536
+ * asynchronous standby.
1537
+ */
1538
+ sync_priority [i ] = XLogRecPtrIsInvalid (walsnd -> flush ) ?
1539
+ 0 : walsnd -> sync_standby_priority ;
1534
1540
1535
1541
if (walsnd -> state == WALSNDSTATE_STREAMING &&
1536
1542
walsnd -> sync_standby_priority > 0 &&
1537
1543
(priority == 0 ||
1538
- priority > walsnd -> sync_standby_priority ))
1544
+ priority > walsnd -> sync_standby_priority ) &&
1545
+ !XLogRecPtrIsInvalid (walsnd -> flush ))
1539
1546
{
1540
1547
priority = walsnd -> sync_standby_priority ;
1541
1548
sync_standby = i ;
You can’t perform that action at this time.
0 commit comments