diff --git a/service/history/queue_factory_base.go b/service/history/queue_factory_base.go index aada788432..c58cec8165 100644 --- a/service/history/queue_factory_base.go +++ b/service/history/queue_factory_base.go @@ -226,9 +226,17 @@ func NewHostRateLimiterRateFn( return float64(maxPollHostRps) } - // ensure queue loading won't consume all persistence tokens - // especially upon host restart when we need to perform a load - // for all shards - return float64(persistenceMaxRPS()) * persistenceMaxRPSRatio + if pMaxRPS := persistenceMaxRPS(); pMaxRPS > 0 { + // ensure queue loading won't consume all persistence tokens + // especially upon host restart when we need to perform a load + // for all shards + return float64(pMaxRPS) * persistenceMaxRPSRatio + } + + // persistenceMaxQPS=0 means "unlimited" — use a high default to avoid + // producing a zero rate which would block all queue readers. + // NOTE: Do not use math.MaxFloat64 here; int(math.MaxFloat64) overflows + // to math.MinInt64, which breaks burst calculation in the rate limiter. + return 100_000 } } diff --git a/service/history/queues/reader.go b/service/history/queues/reader.go index 2f2b2c6fd6..e6bc84708f 100644 --- a/service/history/queues/reader.go +++ b/service/history/queues/reader.go @@ -431,6 +431,7 @@ func (r *ReaderImpl) loadAndSubmitTasks() { // this should never happen r.logger.Error("Queue reader rate limiter burst size is smaller than required token count") + return } r.Lock()