Problem
During UPDATE STATISTICS execution, sys.dm_exec_requests.context_info is NULL for the sp_StatUpdate session. A DBA using sp_WhoIsActive to monitor a running maintenance job sees only the inner dynamic SQL (UPDATE STATISTICS [table] [stat] WITH ...) with no procedural context — no indication that sp_StatUpdate is running, which run label, what stat index out of how many, or when the current stat started. RAISERROR WITH NOWAIT (the existing progress mechanism) feeds the Agent job log only; it does not populate context_info. The two monitoring surfaces (DMV/sp_WhoIsActive vs. job log) require separate instrumentation.
Proposed Fix
SET CONTEXT_INFO (128 bytes): Set at loop entry with a truncated payload encoding RunLabel, stat_index/total_stats, and current stat name. Use SET CONTEXT_INFO (not sp_set_session_context) — sp_WhoIsActive reads context_info, not the newer session context API.
##sp_StatUpdate_Progress column depth: The opt-in progress table (lines 3123–3156) has correct architecture but insufficient columns. Add: CurrentStatName, CurrentStatIndex, TotalStats, CurrentStatStartTime. Makes the table a complete diagnostic surface for dashboard consumers.
- Both changes are orthogonal — neither replaces the existing
RAISERROR WITH NOWAIT job-log progress path.
Draft Source
memory/persona-trickle/blog-drafts/issue-draft-spid-context-info-observability.md
Problem
During UPDATE STATISTICS execution,
sys.dm_exec_requests.context_infois NULL for the sp_StatUpdate session. A DBA using sp_WhoIsActive to monitor a running maintenance job sees only the inner dynamic SQL (UPDATE STATISTICS [table] [stat] WITH ...) with no procedural context — no indication that sp_StatUpdate is running, which run label, what stat index out of how many, or when the current stat started.RAISERROR WITH NOWAIT(the existing progress mechanism) feeds the Agent job log only; it does not populatecontext_info. The two monitoring surfaces (DMV/sp_WhoIsActive vs. job log) require separate instrumentation.Proposed Fix
SET CONTEXT_INFO(128 bytes): Set at loop entry with a truncated payload encodingRunLabel,stat_index/total_stats, and current stat name. UseSET CONTEXT_INFO(notsp_set_session_context) — sp_WhoIsActive readscontext_info, not the newer session context API.##sp_StatUpdate_Progresscolumn depth: The opt-in progress table (lines 3123–3156) has correct architecture but insufficient columns. Add:CurrentStatName,CurrentStatIndex,TotalStats,CurrentStatStartTime. Makes the table a complete diagnostic surface for dashboard consumers.RAISERROR WITH NOWAITjob-log progress path.Draft Source
memory/persona-trickle/blog-drafts/issue-draft-spid-context-info-observability.md