Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit edb5c40

Browse files
committed
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>
1 parent 52acf02 commit edb5c40

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/bin/pgbench/pgbench.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ typedef struct
219219
Variable *variables; /* array of variable definitions */
220220
int nvariables;
221221
int64 txn_scheduled; /* scheduled start time of transaction (usec) */
222+
int64 sleep_until; /* scheduled start time of next cmd (usec) */
222223
instr_time txn_begin; /* used for measuring schedule lag times */
223224
instr_time stmt_begin; /* used for measuring statement latencies */
224225
int64 txn_latencies; /* cumulated latencies */
@@ -1238,6 +1239,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
12381239
}
12391240
}
12401241

1242+
st->sleep_until = st->txn_scheduled;
12411243
st->sleeping = 1;
12421244
st->throttling = true;
12431245
st->is_throttled = true;
@@ -1253,7 +1255,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
12531255
if (INSTR_TIME_IS_ZERO(now))
12541256
INSTR_TIME_SET_CURRENT(now);
12551257
now_us = INSTR_TIME_GET_MICROSEC(now);
1256-
if (st->txn_scheduled <= now_us)
1258+
if (st->sleep_until <= now_us)
12571259
{
12581260
st->sleeping = 0; /* Done sleeping, go ahead with next command */
12591261
if (st->throttling)
@@ -1721,7 +1723,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
17211723
usec *= 1000000;
17221724

17231725
INSTR_TIME_SET_CURRENT(now);
1724-
st->txn_scheduled = INSTR_TIME_GET_MICROSEC(now) + usec;
1726+
st->sleep_until = INSTR_TIME_GET_MICROSEC(now) + usec;
17251727
st->sleeping = 1;
17261728

17271729
st->listen = 1;

0 commit comments

Comments
 (0)