Skip to content

Blocking counts still include a parallel query waiting on its own threads (#5633 item 1, not covered by #5704) #6645

Closed

Description

@erikdarlingdata

Claude posting for Erik Darling.

What happens

A parallel query whose threads wait on each other is still counted as blocking. It inflates the blocking event count, the head blocker count and the chain facts. It also feeds the "N blocking events" anomaly. This was item 1 of #5633. It is still present in v3.11.0 (1b6af51).

#5704 has no lane for it, because the #5633 triage said "There is no defect 1". #5705 says "No self-blocking filter (that is #5633 M1)". So neither PR fixed it.

What I saw

Build: v3.11.0, managed PostgreSQL 18 + TimescaleDB store. The data is a replay of 2026-10-07 and 2026-10-08 on one 16-CPU SQL Server 2022 test instance. That window holds exactly one real lock wait, an X lock on a KEY. Every other report is one SQLCMD parallel query.

The self-blocked reports look like this (get_blocking with as_of 2026-10-08T23:42:14Z):

Field Value
blocked_spid / blocked_ecid 59 / 2, 5, 6
blocking_spid / blocking_ecid 59 / 1
lock_mode empty string
wait_resource null
blocked_status suspended

What the tools report for the same window:

Read Value Expected
get_analysis_facts (source blocking, hours_back 48, as_of 2026-10-08T23:42:14Z): BLOCKING_EVENTS event_count 13 1
same: distinct_head_blockers 3 1
same: BLOCKING_CHAIN worst_apex_spid 59, cycle_detected 1 no chain
analyze_server (same window): ANOMALY_BLOCKING_SPIKE "59 blocking events this window" 1
get_daily_summary 2026-10-07 + 2026-10-08: blocking_events 1 + 12 1

W1 (#5705) shrank the count from 59 reports to 13 waits. It did not remove the self-waits. The chain reconstruction treats the self edge (spid 59 to spid 59) as a cycle.

Where

  • PerformanceMonitor.Common/BlockingWaits.cs: WaitsCteSql and Collapse. This is the shared definition of a wait.
  • Darling/PerformanceMonitor.Darling.Analysis/PgFactCollector.Waits.cs:277 BuildBlockingSql (BLOCKING_EVENTS). The chain reconstruction sets cycle_detected at about line 712.
  • PerformanceMonitor.Alerting/AlertContextBuilders.cs:497 BlockingWaitRows (the alert value and card).
  • The fleet tile (FleetBlockingSql), get_server_summary, the daily summary, and the report counts the health band and anomaly detectors use.
  • Lite: Lite/Analysis/DuckDbFactCollector.Waits.cs and the Lite overview.

Suggested fix

Leave out rows where blocked_spid = blocking_spid wherever a report becomes a blocking wait. These are intra-query parallelism waits, not lock blocking. Do it once, in BlockingWaits (both the C# and the SQL text). Then do the same in the chain reconstruction and in the report count that the band tiers and the anomaly detectors read.

get_blocking can keep the rows. It could mark them, for example with intra_query: true, so the raw read still shows what SQL Server wrote.

How to verify

  • A fixture with a self-blocked parallel report set plus one real lock wait gives event_count 1, distinct_head_blockers 1 and no cycle.
  • On a live store, rerun the replay reads above with the same as_of. The 10-08 rows are kept for 30 days, until about 2026-11-07.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclient-siteOwned by the client-site agents (other laptop). Local sessions never pick these up.owner:pm-worker-coordinatorLaptop coordinator session

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions