Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

SqlClient fix managed MARS timeout cancellation #38266

Merged
merged 2 commits into from
Oct 15, 2019
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 @@ -136,7 +136,10 @@ public void HandleReceiveError(SNIPacket packet)
Debug.Assert(Monitor.IsEntered(this), "HandleReceiveError was called without being locked.");
foreach (SNIMarsHandle handle in _sessions.Values)
{
handle.HandleReceiveError(packet);
if (packet.HasCompletionCallback)
{
handle.HandleReceiveError(packet);
}
}
packet?.Release();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public SNIPacket(int headerSize, int dataSize)
/// </summary>
public bool IsInvalid => _data is null;

public bool HasCompletionCallback => !(_completionCallback is null);

/// <summary>
/// Packet data
/// </summary>
public void Dispose() => Release();

public int ReservedHeaderSize => _headerLength;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public static class ConnectionPoolTest
private static readonly string _tcpMarsConnStr = (new SqlConnectionStringBuilder(DataTestUtility.TcpConnStr) { MultipleActiveResultSets = true, Pooling = true }).ConnectionString;


[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup), /* [ActiveIssue(33930)]: */ nameof(DataTestUtility.IsUsingNativeSNI))]
[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup))]
public static void ConnectionPool_NonMars()
{
RunDataTestForSingleConnString(_tcpConnStr);
}

[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup), /* [ActiveIssue(33930)] */ nameof(DataTestUtility.IsUsingNativeSNI))]
[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup))]
public static void ConnectionPool_Mars()
{
RunDataTestForSingleConnString(_tcpMarsConnStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class PoolBlockPeriodTest
private const int ConnectionTimeout = 15;
private const int CompareMargin = 2;

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), /* [ActiveIssue(33930)] */ nameof(DataTestUtility.IsUsingNativeSNI))]
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[InlineData("Azure with Default Policy must Disable blocking (*.database.windows.net)", new object[] { AzureEndpointSample })]
[InlineData("Azure with Default Policy must Disable blocking (*.database.chinacloudapi.cn)", new object[] { AzureChinaEnpointSample })]
[InlineData("Azure with Default Policy must Disable blocking (*.database.usgovcloudapi.net)", new object[] { AzureUSGovernmentEndpointSample })]
Expand All @@ -45,7 +45,7 @@ public void TestAzureBlockingPeriod(string description, object[] Params)
PoolBlockingPeriodAzureTest(connString, policy);
}

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), /* [ActiveIssue(33930)] */ nameof(DataTestUtility.IsUsingNativeSNI))]
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[InlineData("NonAzure with Default Policy must Enable blocking", new object[] { NonExistentServer })]
[InlineData("NonAzure with Auto Policy must Enable Blocking", new object[] { NonExistentServer, PoolBlockingPeriod.Auto })]
[InlineData("NonAzure with Always Policy must Enable Blocking", new object[] { NonExistentServer, PoolBlockingPeriod.AlwaysBlock })]
Expand All @@ -66,7 +66,7 @@ public void TestNonAzureBlockingPeriod(string description, object[] Params)
PoolBlockingPeriodNonAzureTest(connString, policy);
}

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), /* [ActiveIssue(33930)] */ nameof(DataTestUtility.IsUsingNativeSNI))]
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[InlineData("Test policy with Auto (lowercase)", "auto")]
[InlineData("Test policy with Auto (PascalCase)", "Auto")]
[InlineData("Test policy with Always (lowercase)", "alwaysblock")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ private static void RunAllTestsForSingleServer(string connectionString, bool usi
// These tests fail with named pipes, since they try to do DNS lookups on named pipe paths.
if (!usingNamePipes)
{
//if (DataTestUtility.IsUsingNativeSNI()) /* [ActiveIssue(33930)] */
//{
// TimeoutDuringReadAsyncWithClosedReaderTest(connectionString);
//}
if (DataTestUtility.IsUsingNativeSNI())
{
TimeoutDuringReadAsyncWithClosedReaderTest(connectionString);
}
NonFatalTimeoutDuringRead(connectionString);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void NamedPipesMARSTest()
}

#if DEBUG
[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup), /* [ActiveIssue(33930)] */ nameof(DataTestUtility.IsUsingNativeSNI))]
[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup))]
public static void MARSAsyncTimeoutTest()
{
using (SqlConnection connection = new SqlConnection(_connStr))
Expand Down Expand Up @@ -73,7 +73,7 @@ public static void MARSAsyncTimeoutTest()
}
}

[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup), /* [ActiveIssue(33930)] */ nameof(DataTestUtility.IsUsingNativeSNI))]
[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup))]
public static void MARSSyncTimeoutTest()
{
using (SqlConnection connection = new SqlConnection(_connStr))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace System.Data.SqlClient.ManualTesting.Tests
public static class SqlCredentialTest
{

[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup), /* [ActiveIssue(33930)] */ nameof(DataTestUtility.IsUsingNativeSNI))]
[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup))]
public static void CreateSqlConnectionWithCredential()
{
var user = "u" + Guid.NewGuid().ToString().Replace("-", "");
Expand Down Expand Up @@ -49,7 +49,7 @@ public static void CreateSqlConnectionWithCredential()
}
}

[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup), /* [ActiveIssue(33930)] */ nameof(DataTestUtility.IsUsingNativeSNI))]
[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup))]
public static void SqlConnectionChangePasswordPlaintext()
{
var user = "u" + Guid.NewGuid().ToString().Replace("-", "");
Expand Down Expand Up @@ -82,7 +82,7 @@ public static void SqlConnectionChangePasswordPlaintext()
}
}

[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup), /* [ActiveIssue(33930)] */ nameof(DataTestUtility.IsUsingNativeSNI))]
[ConditionalFact(typeof(DataTestUtility),nameof(DataTestUtility.AreConnStringsSetup))]
public static void SqlConnectionChangePasswordSecureString()
{
var user = "u" + Guid.NewGuid().ToString().Replace("-", "");
Expand Down Expand Up @@ -122,7 +122,7 @@ public static void SqlConnectionChangePasswordSecureString()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), /* [ActiveIssue(33930)] */ nameof(DataTestUtility.IsUsingNativeSNI))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
public static void OldCredentialsShouldFail()
{
String user = "u" + Guid.NewGuid().ToString().Replace("-", "");
Expand Down