Author: Noah Misch Commit: Noah Misch (not for commit) Reproduce failure seen here: https://postgr.es/m/CAEepm=1MzM2Z_xNe4foGwZ1a+MO_2S9oYDq3M5D11=JDU_+0Nw@mail.gmail.com https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=frogfish&dt=2020-03-07%2018%3A49%3A34 diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index 7717bb2..2268009 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -1448,7 +1448,8 @@ internal_flush(void) last_reported_send_errno = errno; ereport(COMMERROR, (errcode_for_socket_access(), - errmsg("could not send data to client: %m"))); + errmsg("could not send data to client: %m"), + errbacktrace())); } /* diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index ae4a9cb..d660038 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -1229,6 +1229,19 @@ WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid, if (pq_flush_if_writable() != 0) WalSndShutdown(); + /* + * If this XLogData message causes pg_recvlogical to reach its --endpos, + * pg_recvlogical will exit during this sleep. + */ + pg_usleep(15 * 1000); + /* + * Send a long NoticeResponse. If the peer has exited, internal_flush() + * will observe EPIPE and ereport(COMMERROR). + */ + elog(WARNING, "long notice %065535d", 7); + if (pq_flush_if_writable() != 0) + WalSndShutdown(); + /* Try taking fast path unless we get too close to walsender timeout. */ if (now < TimestampTzPlusMilliseconds(last_reply_timestamp, wal_sender_timeout / 2) &&