@@ -516,26 +516,28 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
516516 if (!CheckServerVersionForStreaming (conn ))
517517 return false;
518518
519+ /*
520+ * Decide whether we want to report the flush position. If we report
521+ * the flush position, the primary will know what WAL we'll
522+ * possibly re-request, and it can then remove older WAL safely.
523+ * We must always do that when we are using slots.
524+ *
525+ * Reporting the flush position makes one eligible as a synchronous
526+ * replica. People shouldn't include generic names in
527+ * synchronous_standby_names, but we've protected them against it so
528+ * far, so let's continue to do so unless specifically requested.
529+ */
519530 if (replication_slot != NULL )
520531 {
521- /*
522- * Report the flush position, so the primary can know what WAL we'll
523- * possibly re-request, and remove older WAL safely.
524- *
525- * We only report it when a slot has explicitly been used, because
526- * reporting the flush position makes one eligible as a synchronous
527- * replica. People shouldn't include generic names in
528- * synchronous_standby_names, but we've protected them against it so
529- * far, so let's continue to do so in the situations when possible. If
530- * they've got a slot, though, we need to report the flush position,
531- * so that the master can remove WAL.
532- */
533532 reportFlushPosition = true;
534533 sprintf (slotcmd , "SLOT \"%s\" " , replication_slot );
535534 }
536535 else
537536 {
538- reportFlushPosition = false;
537+ if (stream -> synchronous )
538+ reportFlushPosition = true;
539+ else
540+ reportFlushPosition = false;
539541 slotcmd [0 ] = 0 ;
540542 }
541543
0 commit comments