Skip to content

Disable packet multiplexing design by default #3537

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

Merged
merged 3 commits into from
Aug 22, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,21 @@ static LocalAppContextSwitches()
#endif

/// <summary>
/// In TdsParser the ProcessSni function changed significantly when the packet
/// In TdsParser, the ProcessSni function changed significantly when the packet
/// multiplexing code needed for high speed multi-packet column values was added.
/// In case of compatibility problems this switch will change TdsParser to use
/// the previous version of the function.
/// When this switch is set to true (the default), the old ProcessSni design is used.
/// When this switch is set to false, the new experimental ProcessSni behavior using
/// the packet multiplexer is enabled.
/// </summary>
public static bool UseCompatibilityProcessSni
{
get
{
if (s_useCompatibilityProcessSni == Tristate.NotInitialized)
{
if (AppContext.TryGetSwitch(UseCompatibilityProcessSniString, out bool returnedValue) && returnedValue)
// Check if the switch has been set by the AppContext switch directly
// If it has not been set, we default to true.
if (!AppContext.TryGetSwitch(UseCompatibilityProcessSniString, out bool returnedValue) || returnedValue)
{
s_useCompatibilityProcessSni = Tristate.True;
}
Expand All @@ -92,12 +95,12 @@ public static bool UseCompatibilityProcessSni
}

/// <summary>
/// In TdsParser the async multi-packet column value fetch behaviour is capable of
/// using a continue snapshot state in addition to the original replay from start
/// logic.
/// This switch disables use of the continue snapshot state. This switch will always
/// return true if <see cref="UseCompatibilityProcessSni"/> is enabled because the
/// continue state is not stable without the multiplexer.
/// In TdsParser, the async multi-packet column value fetch behavior can use a continue snapshot state
/// for improved efficiency. When this switch is enabled (the default), the driver preserves the legacy
/// compatibility behavior, which does not use the continue snapshot state. When disabled, the new behavior
/// using the continue snapshot state is enabled. This switch will always return true if
/// <see cref="UseCompatibilityProcessSni"/> is enabled, because the continue state is not stable without
/// the multiplexer.
/// </summary>
public static bool UseCompatibilityAsyncBehaviour
{
Expand All @@ -114,7 +117,7 @@ public static bool UseCompatibilityAsyncBehaviour

if (s_useCompatibilityAsyncBehaviour == Tristate.NotInitialized)
{
if (AppContext.TryGetSwitch(UseCompatibilityAsyncBehaviourString, out bool returnedValue) && returnedValue)
if (!AppContext.TryGetSwitch(UseCompatibilityAsyncBehaviourString, out bool returnedValue) || returnedValue)
{
s_useCompatibilityAsyncBehaviour = Tristate.True;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static bool IsUsingCompatibilityProcessSni
{
return foundValue;
}
return false;
return true; // Default to true if the switch is not set
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public void TestDefaultAppContextSwitchValues()
Assert.False(LocalAppContextSwitches.MakeReadAsyncBlocking);
Assert.True(LocalAppContextSwitches.UseMinimumLoginTimeout);
Assert.True(LocalAppContextSwitches.LegacyVarTimeZeroScaleBehaviour);
Assert.False(LocalAppContextSwitches.UseCompatibilityProcessSni);
Assert.False(LocalAppContextSwitches.UseCompatibilityAsyncBehaviour);
Assert.True(LocalAppContextSwitches.UseCompatibilityProcessSni);
Assert.True(LocalAppContextSwitches.UseCompatibilityAsyncBehaviour);
Assert.False(LocalAppContextSwitches.UseConnectionPoolV2);
Assert.False(LocalAppContextSwitches.TruncateScaledDecimal);
#if NETFRAMEWORK
Expand Down
Loading