Skip to content
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

Fixes SqlClient behavior of sending Attention signal for successful Bulk Copy operation #61

Merged
merged 1 commit into from
Nov 15, 2019
Merged
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 @@ -2561,7 +2561,7 @@ private void CopyBatchesAsyncContinuedOnError(bool cleanupParser)

if (_stateObj != null)
{
CleanUpStateObjectOnError();
CleanUpStateObject();
}
}
catch (OutOfMemoryException)
Expand All @@ -2584,7 +2584,7 @@ private void CopyBatchesAsyncContinuedOnError(bool cleanupParser)
}

// Cleans the stateobj. Used in a number of places, specially in exceptions.
private void CleanUpStateObjectOnError()
private void CleanUpStateObject(bool isCancelRequested = true)
{
if (_stateObj != null)
{
Expand All @@ -2594,7 +2594,7 @@ private void CleanUpStateObjectOnError()
_stateObj.ResetBuffer();
_stateObj.ResetPacketCounters();
// If _parser is closed, sending attention will raise debug assertion, so we avoid it (but not calling CancelRequest).
if (_parser.State == TdsParserState.OpenNotLoggedIn || _parser.State == TdsParserState.OpenLoggedIn)
if (isCancelRequested && (_parser.State == TdsParserState.OpenNotLoggedIn || _parser.State == TdsParserState.OpenLoggedIn))
{
_stateObj.CancelRequest();
}
Expand Down Expand Up @@ -2655,7 +2655,7 @@ private void WriteToServerInternalRestContinuedAsync(BulkCopySimpleResultSet int
_localColumnMappings = null;
try
{
CleanUpStateObjectOnError();
CleanUpStateObject();
}
finally
{
Expand All @@ -2671,7 +2671,7 @@ private void WriteToServerInternalRestContinuedAsync(BulkCopySimpleResultSet int
_localColumnMappings = null;
try
{
CleanUpStateObjectOnError();
CleanUpStateObject(isCancelRequested: false);
}
finally
{
Expand All @@ -2698,11 +2698,11 @@ private void WriteToServerInternalRestContinuedAsync(BulkCopySimpleResultSet int

try
{
CleanUpStateObjectOnError();
CleanUpStateObject(isCancelRequested: false);
}
catch (Exception cleanupEx)
{
Debug.Fail("Unexpected exception during CleanUpstateObjectOnError (ignored)", cleanupEx.ToString());
Debug.Fail($"Unexpected exception during {nameof(CleanUpStateObject)} (ignored)", cleanupEx.ToString());
}

if (source != null)
Expand All @@ -2717,11 +2717,11 @@ private void WriteToServerInternalRestContinuedAsync(BulkCopySimpleResultSet int

try
{
CleanUpStateObjectOnError();
CleanUpStateObject();
}
catch (Exception cleanupEx)
{
Debug.Fail("Unexpected exception during CleanUpstateObjectOnError (ignored)", cleanupEx.ToString());
Debug.Fail($"Unexpected exception during {nameof(CleanUpStateObject)} (ignored)", cleanupEx.ToString());
}

if (source != null)
Expand Down