9.5a1 BUG FIX: pgbench negative latencies

Started by Fabien COELHOover 10 years ago2 messages
#1Fabien COELHO
coelho@cri.ensmp.fr
1 attachment(s)

Under 9.5a1 "pgbench -r" negative latencies are reported on meta commands,
probably as an oversight of 84f0ea3f.

This patch ensures that "now" is reset on each loop inside doCustom.

--
Fabien.

Attachments:

95a1-pgbench-latencies.patchtext/x-diff; name=95a1-pgbench-latencies.patchDownload
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 2c3e365..cce67e8 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -1146,16 +1146,19 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
 	bool		trans_needs_throttle = false;
 	instr_time	now;
 
+top:
 	/*
 	 * gettimeofday() isn't free, so we get the current timestamp lazily the
 	 * first time it's needed, and reuse the same value throughout this
 	 * function after that. This also ensures that e.g. the calculated latency
 	 * reported in the log file and in the totals are the same. Zero means
 	 * "not set yet".
+	 *
+	 * "now" must also be reset on "goto top;" issued when interpreting meta
+	 * commands, otherwise the per-command measured latency is wrong.
 	 */
 	INSTR_TIME_SET_ZERO(now);
 
-top:
 	commands = sql_files[st->use_file];
 
 	/*
#2Heikki Linnakangas
hlinnaka@iki.fi
In reply to: Fabien COELHO (#1)
Re: 9.5a1 BUG FIX: pgbench negative latencies

On 07/27/2015 03:43 PM, Fabien COELHO wrote:

Under 9.5a1 "pgbench -r" negative latencies are reported on meta commands,
probably as an oversight of 84f0ea3f.

This patch ensures that "now" is reset on each loop inside doCustom.

Applied, thanks!

- Heikki

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers