Skip to content

Commit 075ba6d

Browse files
committed
REMOVE THE RELIABILITY SECTION!
1 parent 46e8714 commit 075ba6d

File tree

16 files changed

+1245
-2220
lines changed

16 files changed

+1245
-2220
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.netcore.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@ internal bool ValidateSNIConnection()
298298
// This method should only be called by ReadSni! If not - it may have problems with timeouts!
299299
private void ReadSniError(TdsParserStateObject stateObj, uint error)
300300
{
301-
TdsParser.ReliabilitySection.Assert("unreliable call to ReadSniSyncError"); // you need to setup for a thread abort somewhere before you call this method
302-
303301
if (TdsEnums.SNI_WAIT_TIMEOUT == error)
304302
{
305303
Debug.Assert(_syncOverAsync, "Should never reach here with async on!");
@@ -753,8 +751,6 @@ public void WriteAsyncCallback(IntPtr key, PacketHandle packet, uint sniError)
753751
//
754752
internal void WriteSecureString(SecureString secureString)
755753
{
756-
TdsParser.ReliabilitySection.Assert("unreliable call to WriteSecureString"); // you need to setup for a thread abort somewhere before you call this method
757-
758754
Debug.Assert(_securePasswords[0] == null || _securePasswords[1] == null, "There are more than two secure passwords");
759755

760756
int index = _securePasswords[0] != null ? 1 : 0;
@@ -829,8 +825,6 @@ internal Task WaitForAccumulatedWrites()
829825
// and then the buffer is re-initialized in flush() and then the byte is put in the buffer.
830826
internal void WriteByte(byte b)
831827
{
832-
TdsParser.ReliabilitySection.Assert("unreliable call to WriteByte"); // you need to setup for a thread abort somewhere before you call this method
833-
834828
Debug.Assert(_outBytesUsed <= _outBuff.Length, "ERROR - TDSParser: _outBytesUsed > _outBuff.Length");
835829

836830
// check to make sure we haven't used the full amount of space available in the buffer, if so, flush it
@@ -866,8 +860,6 @@ private Task WriteBytes(ReadOnlySpan<byte> b, int len, int offsetBuffer, bool ca
866860
}
867861
try
868862
{
869-
TdsParser.ReliabilitySection.Assert("unreliable call to WriteByteArray"); // you need to setup for a thread abort somewhere before you call this method
870-
871863
bool async = _parser._asyncWrite; // NOTE: We are capturing this now for the assert after the Task is returned, since WritePacket will turn off async if there is an exception
872864
Debug.Assert(async || _asyncWriteCount == 0);
873865
// Do we have to send out in packet size chunks, or can we rely on netlib layer to break it up?

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs

Lines changed: 28 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,58 +2059,40 @@ private Task WriteRowSourceToServerAsync(int columnCount, CancellationToken ctok
20592059
RuntimeHelpers.PrepareConstrainedRegions();
20602060
try
20612061
{
2062-
#if DEBUG
2063-
TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection();
2064-
2065-
RuntimeHelpers.PrepareConstrainedRegions();
2066-
try
2067-
{
2068-
tdsReliabilitySection.Start();
2069-
#else // !DEBUG
2070-
{
2071-
#endif //DEBUG
2072-
bestEffortCleanupTarget = SqlInternalConnection.GetBestEffortCleanupTarget(_connection);
2073-
WriteRowSourceToServerCommon(columnCount); //this is common in both sync and async
2074-
Task resultTask = WriteToServerInternalAsync(ctoken); // resultTask is null for sync, but Task for async.
2075-
if (resultTask != null)
2076-
{
2077-
finishedSynchronously = false;
2078-
return resultTask.ContinueWith(
2079-
static (Task task, object state) =>
2062+
bestEffortCleanupTarget = SqlInternalConnection.GetBestEffortCleanupTarget(_connection);
2063+
WriteRowSourceToServerCommon(columnCount); //this is common in both sync and async
2064+
Task resultTask = WriteToServerInternalAsync(ctoken); // resultTask is null for sync, but Task for async.
2065+
if (resultTask != null)
2066+
{
2067+
finishedSynchronously = false;
2068+
return resultTask.ContinueWith(
2069+
static (Task task, object state) =>
2070+
{
2071+
SqlBulkCopy sqlBulkCopy = (SqlBulkCopy)state;
2072+
try
20802073
{
2081-
SqlBulkCopy sqlBulkCopy = (SqlBulkCopy)state;
2082-
try
2074+
sqlBulkCopy.AbortTransaction(); // if there is one, on success transactions will be commited
2075+
}
2076+
finally
2077+
{
2078+
sqlBulkCopy._isBulkCopyingInProgress = false;
2079+
if (sqlBulkCopy._parser != null)
20832080
{
2084-
sqlBulkCopy.AbortTransaction(); // if there is one, on success transactions will be commited
2081+
sqlBulkCopy._parser._asyncWrite = false;
20852082
}
2086-
finally
2083+
if (sqlBulkCopy._parserLock != null)
20872084
{
2088-
sqlBulkCopy._isBulkCopyingInProgress = false;
2089-
if (sqlBulkCopy._parser != null)
2090-
{
2091-
sqlBulkCopy._parser._asyncWrite = false;
2092-
}
2093-
if (sqlBulkCopy._parserLock != null)
2094-
{
2095-
sqlBulkCopy._parserLock.Release();
2096-
sqlBulkCopy._parserLock = null;
2097-
}
2085+
sqlBulkCopy._parserLock.Release();
2086+
sqlBulkCopy._parserLock = null;
20982087
}
2099-
return task;
2100-
},
2101-
state: this,
2102-
scheduler: TaskScheduler.Default
2103-
).Unwrap();
2104-
}
2105-
return null;
2106-
}
2107-
2108-
#if DEBUG
2109-
finally
2110-
{
2111-
tdsReliabilitySection.Stop();
2088+
}
2089+
return task;
2090+
},
2091+
state: this,
2092+
scheduler: TaskScheduler.Default
2093+
).Unwrap();
21122094
}
2113-
#endif //DEBUG
2095+
return null;
21142096
}
21152097
catch (System.OutOfMemoryException e)
21162098
{
@@ -2796,13 +2778,6 @@ private void CopyBatchesAsyncContinuedOnError(bool cleanupParser)
27962778
RuntimeHelpers.PrepareConstrainedRegions();
27972779
try
27982780
{
2799-
#if DEBUG
2800-
TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection();
2801-
RuntimeHelpers.PrepareConstrainedRegions();
2802-
try
2803-
{
2804-
tdsReliabilitySection.Start();
2805-
#endif //DEBUG
28062781
if ((cleanupParser) && (_parser != null) && (_stateObj != null))
28072782
{
28082783
_parser._asyncWrite = false;
@@ -2815,13 +2790,6 @@ private void CopyBatchesAsyncContinuedOnError(bool cleanupParser)
28152790
{
28162791
CleanUpStateObject();
28172792
}
2818-
#if DEBUG
2819-
}
2820-
finally
2821-
{
2822-
tdsReliabilitySection.Stop();
2823-
}
2824-
#endif //DEBUG
28252793
}
28262794
catch (OutOfMemoryException)
28272795
{

0 commit comments

Comments
 (0)