487
488
// call with lock held
489
>
func (d *matcherData) allowForwarding() (allowForwarding bool) {
matcher_data.go
490
>
// If there is a non-negligible backlog, we pause forwarding to make sure
491
>
// root and leaf partitions are treated equally and can process their
492
>
// backlog at the same rate. Stopping task forwarding, prevent poll
493
>
// forwarding as well (in presence of a backlog). This ensures all partitions
494
>
// receive polls and tasks at the same rate.
495
>
//
496
>
// Exception: we allow forward if this partition has not got any polls
497
>
// recently. This is helpful when there are very few pollers and they
498
>
// and they are all stuck in the wrong (root) partition. (Note that since
499
>
// frontend balanced the number of pending pollers per partition this only
500
>
// becomes an issue when the pollers are fewer than the partitions)
501
>
//
502
>
// If allowForwarding was false and changes to true due solely to the passage
503
>
// of time, then we should ensure that match() is called again so that
504
>
// pending tasks/polls can now be forwarded. When does that happen? if
505
>
// isBacklogNegligible changes from false to true, or if we no longer have
506
>
// recent polls.
507
>
//
508
>
// With time, backlog age gets larger, so isBacklogNegligible can go from
509
>
// true to false and not the other way, so that's safe. But it is possible
510
>
// that we no longer have recent polls. So we need to ensure that match() is
511
>
// called again in that case, using reconsiderForwardTimer.
512
>
if d.isBacklogNegligible() {
513
d.reconsiderForwardTimer.unset()
514
return true