diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 94b06d7058..7a058bdae4 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -6262,7 +6262,10 @@ threadRun(void *arg)
 		for (int i = 0; i < nstate; i++)
 		{
 			if ((state[i].con = doConnect()) == NULL)
+			{
+				pthread_barrier_wait(&barrier);
 				goto done;
+			}
 		}
 
 		/* compute connection delay */
