aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2016-09-19 22:55:43 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2016-09-19 22:55:50 +0300
commitf65764a04a0cccbcd53bf413d6f73ecedaae21c6 (patch)
treeba87f46e0b8eed3c37261d66dea61ea54308f47d
parent156f974f56543365b89f96182e9dfa16f4287e9a (diff)
downloadpostgresql-f65764a04a0cccbcd53bf413d6f73ecedaae21c6.tar.gz
postgresql-f65764a04a0cccbcd53bf413d6f73ecedaae21c6.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.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 87fb006d879..f3d51196843 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -250,6 +250,7 @@ typedef struct
int nvariables; /* number of variables */
bool vars_sorted; /* are variables sorted by name? */
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 */
int use_file; /* index in sql_scripts for this client */
@@ -1828,6 +1829,7 @@ top:
}
}
+ st->sleep_until = st->txn_scheduled;
st->sleeping = true;
st->throttling = true;
st->is_throttled = true;
@@ -1840,7 +1842,7 @@ top:
{ /* are we sleeping? */
if (INSTR_TIME_IS_ZERO(now))
INSTR_TIME_SET_CURRENT(now);
- if (INSTR_TIME_GET_MICROSEC(now) < st->txn_scheduled)
+ if (INSTR_TIME_GET_MICROSEC(now) < st->sleep_until)
return true; /* Still sleeping, nothing to do here */
/* Else done sleeping, go ahead with next command */
st->sleeping = false;
@@ -2138,7 +2140,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 = true;
st->listen = true;