When Cloudflare experienced severe latency spikes in their petabyte-scale ClickHouse billing pipeline, standard diagnostic metrics failed to reveal the problem. Disk input and output, memory utilization, row scans, and part reads all appeared entirely normal.
The real issue was buried deep within query planning and primary key compilation. Because their centralized analytics table used a dynamic index identifier inside the primary key to support diverse tenant queries, certain query plans triggered unexpected lock contention inside internal data structures.
Diagnosing issues at this scale requires stepping past high-level database metrics and profiling internal thread execution states directly. If query latency spikes while storage and memory stay quiet, lock contention inside query planning is often the hidden culprit.




