While testing for something else I encountered two small bugs under very low rate (--rate=0.1). The attached patches fixes these.

 - when a duration (-T) is specified, ensure that pgbench ends at that
   time (i.e. do not wait for a transaction beyond the end of the run).

 - when there is a progress (-P) report, ensure that all progress
   reports are shown even if no more transactions are schedule.

--
Fabien.
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index d5f242c..6cd6500 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -1195,6 +1195,12 @@ top:
 		thread->throttle_trigger += wait;
 		st->txn_scheduled = thread->throttle_trigger;
 
+		/* stop client if next transaction is beyond pgbench end of execution */
+		if (duration &&
+			(st->txn_scheduled / 1000000.0) >
+			INSTR_TIME_GET_DOUBLE(thread->start_time) + duration)
+			return false;
+
 		/*
 		 * If this --latency-limit is used, and this slot is already late so
 		 * that the transaction will miss the latency limit even if it
@@ -3674,7 +3680,10 @@ threadRun(void *arg)
 		}
 	}
 
-	while (remains > 0)
+	while (remains > 0 ||
+		   /* thread zero keeps on printing progress report if any */
+		   (progress && thread->tid == 0 && duration &&
+			next_report <= thread_start + (int64) duration * 1000000))
 	{
 		fd_set		input_mask;
 		int			maxsock;	/* max socket number to be waited */
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to