-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Workaround for querying deadlocks in extended events #18781
base: master
Are you sure you want to change the base?
Conversation
The changelog type |
1 similar comment
The changelog type |
The changelog type |
cursor.execute(XE_SESSIONS_QUERY) | ||
rows = cursor.fetchall() | ||
if not rows: | ||
raise Exception(NO_XE_SESSION_ERROR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to create a custom exception class NoXeSessionException(Exception)
so that we can catch the specific exception when needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw i also don't see error handling of in _set_xe_session_name
and _query_deadlocks
. if an exception is raised here, it will fail the thread. should we catch the exception and log an error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The custom exception NoXeSessionException is now raised in _set_xe_session_name
and caught in _query_deadlocks
.
The changelog type |
1 similar comment
The changelog type |
de127bf
to
cefeb94
Compare
The changelog type |
The changelog type |
What does this PR do?
Implements the workaround for querying deadlocks in extended events (XE) views.
Motivation
SQL Server limitation: Querying the extended events ring buffer may not show the latest events.
Additional Notes
The ring buffer in sys.dm_xe_session_targets.target_data is externalized as one large XML, limited to 4MB, even though it's NVARCHAR(MAX). If the XML exceeds 4MB, the latest events are not shown.
To avoid this, we're creating a dedicated datadog XE session with a 1MB buffer, which prevents XML overflow. Since the XML typically uses half the allocated buffer space, a 1MB buffer gives us an 8x safety margin.
Review checklist (to be filled by reviewers)
qa/skip-qa
label if the PR doesn't need to be tested during QA.backport/<branch-name>
label to the PR and it will automatically open a backport PR once this one is merged