Skip to content

Commit 9039870

Browse files
Disable packet multiplexing design by default (#3537)
* Disable packet multiplexing design by default * Update comments * Revert for this PR
1 parent a3e87a4 commit 9039870

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,21 @@ static LocalAppContextSwitches()
6767
#endif
6868

6969
/// <summary>
70-
/// In TdsParser the ProcessSni function changed significantly when the packet
70+
/// In TdsParser, the ProcessSni function changed significantly when the packet
7171
/// multiplexing code needed for high speed multi-packet column values was added.
72-
/// In case of compatibility problems this switch will change TdsParser to use
73-
/// the previous version of the function.
72+
/// When this switch is set to true (the default), the old ProcessSni design is used.
73+
/// When this switch is set to false, the new experimental ProcessSni behavior using
74+
/// the packet multiplexer is enabled.
7475
/// </summary>
7576
public static bool UseCompatibilityProcessSni
7677
{
7778
get
7879
{
7980
if (s_useCompatibilityProcessSni == Tristate.NotInitialized)
8081
{
81-
if (AppContext.TryGetSwitch(UseCompatibilityProcessSniString, out bool returnedValue) && returnedValue)
82+
// Check if the switch has been set by the AppContext switch directly
83+
// If it has not been set, we default to true.
84+
if (!AppContext.TryGetSwitch(UseCompatibilityProcessSniString, out bool returnedValue) || returnedValue)
8285
{
8386
s_useCompatibilityProcessSni = Tristate.True;
8487
}
@@ -92,12 +95,12 @@ public static bool UseCompatibilityProcessSni
9295
}
9396

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

115118
if (s_useCompatibilityAsyncBehaviour == Tristate.NotInitialized)
116119
{
117-
if (AppContext.TryGetSwitch(UseCompatibilityAsyncBehaviourString, out bool returnedValue) && returnedValue)
120+
if (!AppContext.TryGetSwitch(UseCompatibilityAsyncBehaviourString, out bool returnedValue) || returnedValue)
118121
{
119122
s_useCompatibilityAsyncBehaviour = Tristate.True;
120123
}

src/Microsoft.Data.SqlClient/tests/FunctionalTests/MultiplexerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static bool IsUsingCompatibilityProcessSni
2525
{
2626
return foundValue;
2727
}
28-
return false;
28+
return true; // Default to true if the switch is not set
2929
}
3030
}
3131

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/LocalAppContextSwitchesTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public void TestDefaultAppContextSwitchValues()
2323
Assert.False(LocalAppContextSwitches.MakeReadAsyncBlocking);
2424
Assert.True(LocalAppContextSwitches.UseMinimumLoginTimeout);
2525
Assert.True(LocalAppContextSwitches.LegacyVarTimeZeroScaleBehaviour);
26-
Assert.False(LocalAppContextSwitches.UseCompatibilityProcessSni);
27-
Assert.False(LocalAppContextSwitches.UseCompatibilityAsyncBehaviour);
26+
Assert.True(LocalAppContextSwitches.UseCompatibilityProcessSni);
27+
Assert.True(LocalAppContextSwitches.UseCompatibilityAsyncBehaviour);
2828
Assert.False(LocalAppContextSwitches.UseConnectionPoolV2);
2929
Assert.False(LocalAppContextSwitches.TruncateScaledDecimal);
3030
#if NETFRAMEWORK

0 commit comments

Comments
 (0)