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

Commit9031ff9

Browse files
committed
Fix pgbench progress report behaviour when pgbench or a query gets stuck.
There were two issues here. First, if a query got stuck so that it tooke.g. 5 seconds, and progress interval was 1 second, no progress reports wereprinted until the query returned. Fix so that we wake up specifically toprint the progress report. Secondly, if pgbench got stuck so that it wouldnevertheless not print a progress report on time, and enough time passesthat it's already time to print the next progress report, just skip the onethat was missed. Before this patch, it would print the missed one with 0 TPSimmediately after the previous one.Fabien Coelho. Backpatch to 9.4, where progress reports were added.
1 parentba3deee commit9031ff9

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,6 +3649,33 @@ threadRun(void *arg)
36493649
maxsock=sock;
36503650
}
36513651

3652+
/* also wake up to print the next progress report on time */
3653+
if (progress&&min_usec>0
3654+
#if !defined(PTHREAD_FORK_EMULATION)
3655+
&&thread->tid==0
3656+
#endif/* !PTHREAD_FORK_EMULATION */
3657+
)
3658+
{
3659+
/* get current time if needed */
3660+
if (now_usec==0)
3661+
{
3662+
instr_timenow;
3663+
3664+
INSTR_TIME_SET_CURRENT(now);
3665+
now_usec=INSTR_TIME_GET_MICROSEC(now);
3666+
}
3667+
3668+
if (now_usec >=next_report)
3669+
min_usec=0;
3670+
elseif ((next_report-now_usec)<min_usec)
3671+
min_usec=next_report-now_usec;
3672+
}
3673+
3674+
/*
3675+
* Sleep until we receive data from the server, or a nap-time
3676+
* specified in the script ends, or it's time to print a progress
3677+
* report.
3678+
*/
36523679
if (min_usec>0&&maxsock!=-1)
36533680
{
36543681
intnsocks;/* return from select(2) */
@@ -3754,7 +3781,15 @@ threadRun(void *arg)
37543781
last_lags=lags;
37553782
last_report=now;
37563783
last_skipped=thread->throttle_latency_skipped;
3757-
next_report+= (int64)progress*1000000;
3784+
3785+
/*
3786+
* Ensure that the next report is in the future, in case
3787+
* pgbench/postgres got stuck somewhere.
3788+
*/
3789+
do
3790+
{
3791+
next_report+= (int64)progress*1000000;
3792+
}while (now >=next_report);
37583793
}
37593794
}
37603795
#else
@@ -3818,7 +3853,15 @@ threadRun(void *arg)
38183853
last_lags=lags;
38193854
last_report=now;
38203855
last_skipped=thread->throttle_latency_skipped;
3821-
next_report+= (int64)progress*1000000;
3856+
3857+
/*
3858+
* Ensure that the next report is in the future, in case
3859+
* pgbench/postgres got stuck somewhere.
3860+
*/
3861+
do
3862+
{
3863+
next_report+= (int64)progress*1000000;
3864+
}while (now >=next_report);
38223865
}
38233866
}
38243867
#endif/* PTHREAD_FORK_EMULATION */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp