#8451·cadence

Smooth history task DLQ processor load: failover fan-out jitter, host-level concurrency cap, ack-level existence cache, sweep interval jitter

Author: c-warrenCreated Aug 20, 2026Updated Sep 25, 2026
Labelskind/featurearea/history

Description

On domain failover, domainChangeCB (service/history/engine/engineimpl/register_domain_failover_callback.go) runs on every shard as the domain cache refreshes — all shards on a host in the same callback pass, and all hosts within the same cache poll window. Each shard's DLQ processLoop wakes immediately and issues GetHistoryDLQAckLevels + GetHistoryDLQTasks, producing a cluster-wide synchronized query burst (tens of thousands of queries within seconds at production shard counts) with no jitter and no concurrency cap — landing on top of the failover's own load (failover queue setup, queue re-notification scans, replication traffic).

Separately, the periodic sweep interval resets with no jitter (timer.Reset(p.interval(p.shardID)) in processLoop), so after a deploy all shards' 30-minute sweeps run in roughly synchronized waves. Compare emitDLQSizeMetricsLoop in service/history/replication/dlq_handler.go, which uses backoff.JitDuration for exactly this reason.

Proposal, four parts, all in the DLQ processor path:

  1. Per-shard jitter on failover reprocessing: delay each shard's failover-triggered ProcessPartition by a random amount within a dynamic-config window so the burst is spread instead of synchronized.
  2. Host-level concurrency cap: a host-wide semaphore bounding how many shards' DLQ reprocessing runs concurrently, as a hard backstop under the jitter.
  3. Ack-level existence cache, cache-first with DB fallback: before issuing GetHistoryDLQAckLevels for a failover partition, consult a local cache of partitions known to have DLQ rows (the shard already tracks dlqAckLevelsCreated in shardedHistoryTaskDLQWriter). On a cache hit, skip straight to processing. On a cache miss the DB must still be queried — the partition may have been written by a previous owner of the shard on another host, and failovers coincide with heavy shard movement — so the cache only saves the read when it can prove a hit, never skips work on a miss.
  4. Sweep interval jitter: apply backoff.JitDuration (or equivalent) to the periodic sweep timer reset.

Complementary to the missing persistence rate limiter on the DLQ manager (#8449): the rate limiter protects the database when a burst happens; this issue reduces the burst itself.

Is this a breaking change?

  • Yes
  • No

If yes, explain why:

Scope of the feature (server, specific client, all clients)

Server only (history service DLQ processor).

Source: cadence-workflow/cadence