diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 06b22e2..8750dd2 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -1287,7 +1287,7 @@ WalSndLoop(void)
 					ping_sent = true;
 					/* Try to flush pending output to the client */
 					if (pq_flush_if_writable() != 0)
-						break;
+						goto send_failure;
 				}
 			}
 
