BrentOzarULTD / SQL-Server-First-Responder-Kit

sp_Blitz, sp_BlitzCache, sp_BlitzFirst, sp_BlitzIndex, and other SQL Server scripts for health checks and performance tuning.
http://FirstResponderKit.org
Other
3.38k stars 1k forks source link

sp_BlitzFirst: Wait Stats Details does not display correct number of seconds that the server spent waiting #3507

Closed aroques closed 7 months ago

aroques commented 7 months ago

Version of the script Look in the stored procedure, and it'll have a version date & number near the top. Put that in here. If it's not the current version (dated in the last month), then upgrade to the current version and test that before reporting a bug - we fix a lot of stuff in each new build. We'll flat out close bug reports for older builds.

SELECT @Version = '8.19', @VersionDate = '20240222';

What is the current behavior? This Details of the Wait Stats finding displays the @Seconds variable for how long that the server spent waiting on a particular wait (the default is 5 as shown below): image

If the current behavior is a bug, please provide the steps to reproduce. Run sp_BlitzFirst on a server busy enough that it takes longer than @Seconds to run.

What is the expected behavior? This Details of the Wait Stats finding should display the number of seconds that it actually spent waiting which in the above example is 122 seconds.

Which versions of SQL Server and which OS are affected by this issue? Did this work in previous versions of our procedures? Product: Microsoft SQL Server Enterprise: Core-based Licensing (64-bit) Operating System: Windows Server 2016 Standard (10.0) Version: 14.0.3465.1

BrentOzar commented 7 months ago

It does. Do a search in the code for "over the last" and you'll see the relevant portions:

    'For ' + CAST(((wNow.wait_time_ms - COALESCE(wBase.wait_time_ms,0)) / 1000) AS NVARCHAR(100)) + ' seconds over the last ' + CASE @Seconds WHEN 0 THEN (CAST(DATEDIFF(dd,@StartSampleTime,@FinishSampleTime) AS NVARCHAR(10)) + ' days') ELSE (CAST(@Seconds AS NVARCHAR(10)) + ' seconds') END + ', SQL Server was waiting on this particular bottleneck.' + @LineFeed + @LineFeed AS Details,

If you believe that's incorrect, can you send a screenshot that includes these 3 things:

aroques commented 7 months ago

Exact parameters are none so they are defaulted. @Seconds defaults to 5 so the 0 seconds case does not get hit.

The result set and duration are shown in the first screenshot, but here's a complete screenshot of sp_BlitzFirst with defaulted parameters (@Seconds is 5) waiting 12.5 minutes: image

BrentOzar commented 7 months ago

HAHAHA, twelve minutes, good Lord, that's bad. OK, cool, I'll reopen this and get that in, heh.

BrentOzar commented 7 months ago

Fixed! Here's a screenshot showing the server under load. Screenshot 2024-05-01 at 6 56 12 AM