--- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -616,6 +616,17 @@ pqReadData(PGconn *conn) { int available; + /* + * NOT FOR COMMIT: repro aid. Delay reading so that a backend that sends + * an error and exits is gone before we read: the race the Windows + * abortive close loses. + */ + { + const char *d = getenv("PGREPRO_READ_DELAY_MS"); + + if (d != NULL && conn->status != CONNECTION_OK) + pg_usleep(atoi(d) * 1000L); + } if (conn->sock == PGINVALID_SOCKET) { libpq_append_conn_error(conn, "connection not open");