diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2016-09-19 22:55:43 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2016-09-19 22:58:03 +0300 |
commit | edb5c4097604c90e12649cdf24accc6052140b78 (patch) | |
tree | 2a020d3e8a1138b9a58f3252da97a80741b42701 | |
parent | 52acf020a11945ae22a910e3ea784bb23ccdd3a7 (diff) | |
download | postgresql-edb5c4097604c90e12649cdf24accc6052140b78.tar.gz postgresql-edb5c4097604c90e12649cdf24accc6052140b78.zip |
Fix latency calculation when there are \sleep commands in the script.
We can't use txn_scheduled to hold the sleep-until time for \sleep, because
that interferes with calculation of the latency of the transaction as whole.
Backpatch to 9.4, where this bug was introduced.
Fabien COELHO
Discussion: <alpine.DEB.2.20.1608231622170.7102@lancre>
-rw-r--r-- | src/bin/pgbench/pgbench.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 182a9ee1612..75dc57d360c 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -219,6 +219,7 @@ typedef struct Variable *variables; /* array of variable definitions */ int nvariables; int64 txn_scheduled; /* scheduled start time of transaction (usec) */ + int64 sleep_until; /* scheduled start time of next cmd (usec) */ instr_time txn_begin; /* used for measuring schedule lag times */ instr_time stmt_begin; /* used for measuring statement latencies */ int64 txn_latencies; /* cumulated latencies */ @@ -1238,6 +1239,7 @@ top: } } + st->sleep_until = st->txn_scheduled; st->sleeping = 1; st->throttling = true; st->is_throttled = true; @@ -1253,7 +1255,7 @@ top: if (INSTR_TIME_IS_ZERO(now)) INSTR_TIME_SET_CURRENT(now); now_us = INSTR_TIME_GET_MICROSEC(now); - if (st->txn_scheduled <= now_us) + if (st->sleep_until <= now_us) { st->sleeping = 0; /* Done sleeping, go ahead with next command */ if (st->throttling) @@ -1721,7 +1723,7 @@ top: usec *= 1000000; INSTR_TIME_SET_CURRENT(now); - st->txn_scheduled = INSTR_TIME_GET_MICROSEC(now) + usec; + st->sleep_until = INSTR_TIME_GET_MICROSEC(now) + usec; st->sleeping = 1; st->listen = 1; |