Closed DavidWiseman closed 4 days ago
Evaluation of new IOStats_Upd:
Validation check:
SELECT *
FROM [DBADashDB].dbo.DBIOStats_60MIN
WHERE SnapshotDate >= '20240819 10:00'
EXCEPT
SELECT *
FROM [DBADashDB_Clone].dbo.DBIOStats_60MIN
WHERE SnapshotDate >= '20240819 10:00';
SELECT *
FROM [DBADashDB_Clone].dbo.DBIOStats_60MIN
WHERE SnapshotDate >= '20240819 10:00'
EXCEPT
SELECT *
FROM [DBADashDB].dbo.DBIOStats_60MIN
WHERE SnapshotDate >= '20240819 10:00';
Performance check:
The new version appears to be more efficient. Lower duration, CPU & logical reads.
Included in 3.9 🚀
This issue was reported on SQL slack
Microsoft SQL Server 2022 (RTM) - 16.0.1000.6 (X64) Oct 8 2022 05:58:25 Copyright (C) 2022 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)
Note: IOStats_Upd runs every 1min by default so the issue doesn't occur each time the SP is called. When the issue occurs it fails the retry operations. This is an older version of DBA Dash and a RTM version of SQL 2022. There doesn't seem to be any fixes in DBA Dash or SQL 2022 that might address this issue.
There is a primary key on the temp table used by the merge on: InstanceID,DatabaseID,Drive,FileID,SnapshotDate The join condition is: ON S.InstanceID= T.InstanceID AND S.DatabaseID = T.DatabaseID AND S.Drive = T.Drive AND S.FileID = T.FileID AND S.SnapshotDate = T.SnapshotDate
The SnapshotDate is changed changed to the nearest 60min with:
CROSS APPLY [dbo].[DateGroupingMins](SnapshotDate,60) DG
This would be the most obvious place an issue could occur. It's just converting the date to the nearest hour which could result in some duplicates - but it's expected that SnapshotDate is the same value in all rows.
MERGE is known to have some bugs so it's possible the issue is related to a MERGE bug. Although the issue is occurring frequently for the user, the circumstances that trigger it must be quite rare as this issue hasn't previously been observed.
Replacing the MERGE statement with a separate INSERT/UPDATE might not be a bad idea.