On Mon, 14 Jun 2021 16:06:10 +0900 Yugo NAGATA <nag...@sraoss.co.jp> wrote:
> On Mon, 14 Jun 2021 08:47:40 +0200 (CEST) > Fabien COELHO <coe...@cri.ensmp.fr> wrote: > > > I attached the fixed patch that uses return instead of break, and I > > > confirmed > > > that this made the progress reporting work property. > > > > I'm hesitating to do such a strictural change for a degenerate case linked > > to "insane" parameters, as pg is unlikely to reach 100 million tps, ever. > > It seems to me enough that the command is not blocked in such cases. > > Sure. The change from "break" to "return" is just for making the progress > reporting work in the loop, as you mentioned. However, my original intention > is avoiding stuck in a corner-case where a unrealistic parameter was used, and > I agree with you that this change is not so necessary for handling such a > special situation. I attached the v2 patch to clarify that I withdrew the v3 patch. Regards Yugo Nagata -- Yugo NAGATA <nag...@sraoss.co.jp>
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index d7479925cb..fe75533e3e 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -3223,31 +3223,30 @@ advanceConnectionState(TState *thread, CState *st, StatsData *agg) /* * If --latency-limit is used, and this slot is already late * so that the transaction will miss the latency limit even if - * it completed immediately, skip this time slot and schedule - * to continue running on the next slot that isn't late yet. - * But don't iterate beyond the -t limit, if one is given. + * it completed immediately, skip this time slot and loop to + * reschedule. */ if (latency_limit) { pg_time_now_lazy(&now); - while (thread->throttle_trigger < now - latency_limit && - (nxacts <= 0 || st->cnt < nxacts)) + if (thread->throttle_trigger < now - latency_limit) { processXactStats(thread, st, &now, true, agg); - /* next rendez-vous */ - thread->throttle_trigger += - getPoissonRand(&thread->ts_throttle_rs, throttle_delay); - st->txn_scheduled = thread->throttle_trigger; - } - /* - * stop client if -t was exceeded in the previous skip - * loop - */ - if (nxacts > 0 && st->cnt >= nxacts) - { - st->state = CSTATE_FINISHED; + /* stop client if -T/-t was exceeded. */ + if (timer_exceeded || (nxacts > 0 && st->cnt >= nxacts)) + /* + * For very unrealistic rates under -T, some skipped + * transactions are not counted because the catchup + * loop is not fast enough just to do the scheduling + * and counting at the expected speed. + * + * We do not bother with such a degenerate case. + */ + st->state = CSTATE_FINISHED; + + /* otherwise loop over PREPARE_THROTTLE */ break; } }