Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb27d0cd

Browse files
committed
pgbench: Stop counting skipped transactions as soon as timer is exceeded.
When throttling is used, transactions that lag behind schedule bymore than the latency limit are counted and reported as skipped.Previously, there was the case where pgbench counted all skippedtransactions even if the timer specified in -T option was exceeded.This could take a very long time to do that especially when unrealisticallyhigh rate setting in -R option caused quite a lot of transactions thatlagged behind schedule. This could prevent pgbench from endingimmediately, and so pgbench could look like it got stuck to users.To fix the issue, this commit changes pgbench so that it stops countingskipped transactions as soon as the timer is exceeded. The timer canmake pgbench end soon even when there are lots of skipped transactionsthat have not been counted yet.Note that there is no guarantee that all skipped transactions arecounted under -T though there is under -t. This is OK in practicebecause it's very unlikely to happen with realistic setting. Also this isnot the issue that this commit newly introdues. There used to bethe case where pgbench ended without counting all skippedtransactions since before.Back-patch to v14. Per discussion, we decided not to botherback-patch to the stable branches because it's hard to imaginethe issue happens in practice (with realistic setting).Author: Yugo Nagata, Fabien COELHOReviewed-by: Greg Sabino Mullane, Fujii MasaoDiscussion:https://postgr.es/m/20210613040151.265ff59d832f835bbcf8b3ba@sraoss.co.jp
1 parent7430c77 commitb27d0cd

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,31 +3232,36 @@ advanceConnectionState(TState *thread, CState *st, StatsData *agg)
32323232
/*
32333233
* If --latency-limit is used, and this slot is already late
32343234
* so that the transaction will miss the latency limit even if
3235-
* it completed immediately, skip this time slot and schedule
3236-
* to continue running on the next slot that isn't late yet.
3237-
* But don't iterate beyond the -t limit, if one is given.
3235+
* it completed immediately, skip this time slot and loop to
3236+
* reschedule.
32383237
*/
32393238
if (latency_limit)
32403239
{
32413240
pg_time_now_lazy(&now);
32423241

3243-
while (thread->throttle_trigger<now-latency_limit&&
3244-
(nxacts <=0||st->cnt<nxacts))
3242+
if (thread->throttle_trigger<now-latency_limit)
32453243
{
32463244
processXactStats(thread,st,&now, true,agg);
3247-
/* next rendez-vous */
3248-
thread->throttle_trigger+=
3249-
getPoissonRand(&thread->ts_throttle_rs,throttle_delay);
3250-
st->txn_scheduled=thread->throttle_trigger;
3251-
}
32523245

3253-
/*
3254-
* stop client if -t was exceeded in the previous skip
3255-
* loop
3256-
*/
3257-
if (nxacts>0&&st->cnt >=nxacts)
3258-
{
3259-
st->state=CSTATE_FINISHED;
3246+
/*
3247+
* Finish client if -T or -t was exceeded.
3248+
*
3249+
* Stop counting skipped transactions under -T as soon
3250+
* as the timer is exceeded. Because otherwise it can
3251+
* take a very long time to count all of them
3252+
* especially when quite a lot of them happen with
3253+
* unrealistically high rate setting in -R, which
3254+
* would prevent pgbench from ending immediately.
3255+
* Because of this behavior, note that there is no
3256+
* guarantee that all skipped transactions are counted
3257+
* under -T though there is under -t. This is OK in
3258+
* practice because it's very unlikely to happen with
3259+
* realistic setting.
3260+
*/
3261+
if (timer_exceeded|| (nxacts>0&&st->cnt >=nxacts))
3262+
st->state=CSTATE_FINISHED;
3263+
3264+
/* Go back to top of loop with CSTATE_PREPARE_THROTTLE */
32603265
break;
32613266
}
32623267
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp