Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate deadlock events #19139

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sqlserver/changelog.d/19139.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix duplicate deadlock events
7 changes: 4 additions & 3 deletions sqlserver/datadog_checks/sqlserver/deadlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,15 @@ def _query_deadlocks(self):
query = get_deadlocks_query(
convert_xml_to_str=convert_xml_to_str, xe_session_name=self._xe_session_name
)
lookback = self._get_lookback_seconds()
self._log.debug(
"Running query [%s] with max deadlocks %s and timestamp %s",
"Running query %s with max deadlocks %s and lookback %s",
query,
self._max_deadlocks,
self._last_deadlock_timestamp,
lookback,
)
try:
cursor.execute(query, (self._max_deadlocks, self._get_lookback_seconds()))
cursor.execute(query, (self._max_deadlocks, lookback))
except Exception as e:
if "Data column of Unknown ADO type" in str(e):
raise Exception(f"{str(e)} | cursor.description: {cursor.description} | query: {query}")
Expand Down
3 changes: 2 additions & 1 deletion sqlserver/datadog_checks/sqlserver/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,6 @@ def get_deadlocks_query(convert_xml_to_str=False, xe_session_name="datadog"):
AND xt.target_name = N'ring_buffer'
) AS XML_Data
CROSS APPLY Target_Data.nodes('RingBufferTarget/event[@name="xml_deadlock_report"]') AS XEventData(xdr)
WHERE xdr.value('@timestamp', 'datetime') >= DATEADD(SECOND, ?, GETDATE())
WHERE xdr.value('@timestamp', 'datetime')
>= DATEADD(SECOND, ?, TODATETIMEOFFSET(GETDATE(), DATEPART(TZOFFSET, SYSDATETIMEOFFSET())) AT TIME ZONE 'UTC')
;"""
Loading