Skip to content

Conversation

@paulmedynski
Copy link
Contributor

@paulmedynski paulmedynski commented Nov 17, 2025

Description

  • Added max event session duration where that feature is supported.
  • Added test name to event session name.
  • Flattened using blocks to statements.
  • Applied single-branch config to the approver policy (an unrelated change).

Copilot AI review requested due to automatic review settings November 17, 2025 21:46
Copilot finished reviewing on behalf of paulmedynski November 17, 2025 21:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes XEvent test failures by preventing orphaned event sessions through two key improvements: adding automatic session expiration via MAX_DURATION on SQL Server 2017+ and incorporating test names into session names for better traceability.

Key Changes:

  • Added version detection to conditionally set MAX_DURATION for XEvent sessions on SQL Server 2017+
  • Refactored XEventScope to accept test names as session prefixes for improved identification
  • Introduced ServerProperty enum for type-safe server property queries

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
DataTestUtility.cs Added CurrentTestName() helper, ServerProperty enum, refactored GetSqlServerProperty() for type safety, and enhanced XEventScope with version detection and duration support
XEventsTracingTest.cs Converted to instance class with constructor injection to pass test name to XEventScope
DataStreamTest.cs Converted from static to instance class with constructor injection to pass test name to XEventScope

Copilot AI review requested due to automatic review settings November 18, 2025 13:07
Copilot finished reviewing on behalf of paulmedynski November 18, 2025 13:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 11 comments.

cheenamalhotra
cheenamalhotra previously approved these changes Nov 18, 2025
Copilot AI review requested due to automatic review settings November 20, 2025 13:10
Copilot finished reviewing on behalf of paulmedynski November 20, 2025 13:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

.azuredevops/policies/approvercountpolicy.yml:1

  • [nitpick] The original comment referencing a specific Merlinbot PR (line 6 in the old version) has been replaced with a generic documentation link. While the new link is useful, removing the historical reference to the PR that suggested this configuration may reduce traceability. Consider keeping both the original PR reference and the new documentation link.
# This file configures the Approver Count Policy Validator status check.  Some

@paulmedynski paulmedynski marked this pull request as ready for review November 20, 2025 18:31
@paulmedynski paulmedynski requested a review from a team as a code owner November 20, 2025 18:31
Copilot AI review requested due to automatic review settings November 20, 2025 18:31
@paulmedynski paulmedynski changed the title [DRAFT] Fix xevent test failures, avoid orphaned sessions Fix xevent test failures, avoid orphaned sessions Nov 20, 2025
Copilot finished reviewing on behalf of paulmedynski November 20, 2025 18:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

Copy link
Contributor Author

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commentary for reviewers.

- refs/heads/internal/release/5.2
- refs/heads/internal/release/5.1
displayName: dotnet-sqlclient Approver Count Policy
- internal/main
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unrelated change, but it seemed too small to bother with a separate PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to apply this to all branches we maintain? Or can it be done only in the main branch?

if (!string.IsNullOrEmpty(TCPConnectionString))
{
s_sqlServerEngineEdition ??= GetSqlServerProperty(TCPConnectionString, "EngineEdition");
s_sqlServerEngineEdition ??= GetSqlServerProperty(TCPConnectionString, ServerProperty.EngineEdition);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I converted these strings into an enum for consistency.


using DataTestUtility.XEventScope xEventScope =
new DataTestUtility.XEventScope(
_testName,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each XEvent session name will now contain the test name so we can track down the source or orphaned sessions on older SQL Server instances.

Copilot AI review requested due to automatic review settings November 21, 2025 13:33
Copilot finished reviewing on behalf of paulmedynski November 21, 2025 13:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

@paulmedynski paulmedynski marked this pull request as draft November 21, 2025 15:42
@paulmedynski paulmedynski changed the title Fix xevent test failures, avoid orphaned sessions [DRAFT] Fix xevent test failures, avoid orphaned sessions Nov 21, 2025
- Added max event session duration where that feature is supported.
- Added test name to event session name.
- Restricting approve count policy to internal/main.
@paulmedynski paulmedynski changed the title [DRAFT] Fix xevent test failures, avoid orphaned sessions Fix xevent test failures, avoid orphaned sessions Nov 21, 2025
@paulmedynski paulmedynski marked this pull request as ready for review November 21, 2025 16:08
Copilot AI review requested due to automatic review settings November 21, 2025 16:08
Copilot finished reviewing on behalf of paulmedynski November 21, 2025 16:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@paulmedynski
Copy link
Contributor Author

Ignore the Merge Code Coverage job failure - that is being worked on in #3798.

cheenamalhotra
cheenamalhotra previously approved these changes Nov 24, 2025
Copy link
Contributor

@mdaigle mdaigle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One request, otherwise looks good.

}
using SqlCommand command = new SqlCommand(xEventQuery, _connection);

Thread.Sleep(MaxDispatchLatencySeconds * 1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment here on the purpose of this sleep? My read is that we need to wait for the buffered events to get persisted, which may take up to MaxDispatchLatencySeconds seconds.

apoorvdeshmukh
apoorvdeshmukh previously approved these changes Nov 25, 2025
Copilot AI review requested due to automatic review settings November 25, 2025 12:26
Copilot finished reviewing on behalf of paulmedynski November 25, 2025 12:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants