mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +03:00
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>
This commit is contained in:
parent
ca93b816f8
commit
476945c451
@ -211,6 +211,7 @@ typedef struct
|
|||||||
Variable *variables; /* array of variable definitions */
|
Variable *variables; /* array of variable definitions */
|
||||||
int nvariables;
|
int nvariables;
|
||||||
int64 txn_scheduled; /* scheduled start time of transaction (usec) */
|
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 txn_begin; /* used for measuring schedule lag times */
|
||||||
instr_time stmt_begin; /* used for measuring statement latencies */
|
instr_time stmt_begin; /* used for measuring statement latencies */
|
||||||
int64 txn_latencies; /* cumulated latencies */
|
int64 txn_latencies; /* cumulated latencies */
|
||||||
@ -967,6 +968,7 @@ top:
|
|||||||
thread->throttle_trigger += wait;
|
thread->throttle_trigger += wait;
|
||||||
|
|
||||||
st->txn_scheduled = thread->throttle_trigger;
|
st->txn_scheduled = thread->throttle_trigger;
|
||||||
|
st->sleep_until = st->txn_scheduled;
|
||||||
st->sleeping = 1;
|
st->sleeping = 1;
|
||||||
st->throttling = true;
|
st->throttling = true;
|
||||||
st->is_throttled = true;
|
st->is_throttled = true;
|
||||||
@ -982,7 +984,7 @@ top:
|
|||||||
|
|
||||||
INSTR_TIME_SET_CURRENT(now);
|
INSTR_TIME_SET_CURRENT(now);
|
||||||
now_us = INSTR_TIME_GET_MICROSEC(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 */
|
st->sleeping = 0; /* Done sleeping, go ahead with next command */
|
||||||
if (st->throttling)
|
if (st->throttling)
|
||||||
@ -1599,7 +1601,7 @@ top:
|
|||||||
usec *= 1000000;
|
usec *= 1000000;
|
||||||
|
|
||||||
INSTR_TIME_SET_CURRENT(now);
|
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->sleeping = 1;
|
||||||
|
|
||||||
st->listen = 1;
|
st->listen = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user