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

Commitaccf761

Browse files
committed
pgbench: When -T is used, don't wait for transactions beyond end of run.
At low rates, this can lead to pgbench taking significantly longer toterminate than the user might expect. Repair.Fabien Coelho, reviewed by Aleksander Alekseev, Álvaro Herrera, and me.
1 parent188f359 commitaccf761

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static intpthread_join(pthread_t th, void **thread_return);
9494

9595
intnxacts=0;/* number of transactions per client */
9696
intduration=0;/* duration in seconds */
97+
int64end_time=0;/* when to stop in micro seconds, under -T */
9798

9899
/*
99100
* scaling factor. for example, scale = 10 will make 1000000 tuples in
@@ -1362,6 +1363,10 @@ doCustom(TState *thread, CState *st, StatsData *agg)
13621363
thread->throttle_trigger+=wait;
13631364
st->txn_scheduled=thread->throttle_trigger;
13641365

1366+
/* stop client if next transaction is beyond pgbench end of execution */
1367+
if (duration>0&&st->txn_scheduled>end_time)
1368+
returnclientDone(st, true);
1369+
13651370
/*
13661371
* If this --latency-limit is used, and this slot is already late so
13671372
* that the transaction will miss the latency limit even if it
@@ -3582,6 +3587,11 @@ main(int argc, char **argv)
35823587

35833588
INSTR_TIME_SET_CURRENT(thread->start_time);
35843589

3590+
/* compute when to stop */
3591+
if (duration>0)
3592+
end_time=INSTR_TIME_GET_MICROSEC(thread->start_time)+
3593+
(int64)1000000*duration;
3594+
35853595
/* the first thread (i = 0) is executed by main thread */
35863596
if (i>0)
35873597
{
@@ -3600,6 +3610,10 @@ main(int argc, char **argv)
36003610
}
36013611
#else
36023612
INSTR_TIME_SET_CURRENT(threads[0].start_time);
3613+
/* compute when to stop */
3614+
if (duration>0)
3615+
end_time=INSTR_TIME_GET_MICROSEC(threads[0].start_time)+
3616+
(int64)1000000*duration;
36033617
threads[0].thread=INVALID_THREAD;
36043618
#endif/* ENABLE_THREAD_SAFETY */
36053619

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp