Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -3412,6 +3412,8 @@ private bool TryReadInternal(bool setTimeout, out bool more)
{
SqlStatistics statistics = null;
long scopeID = SqlClientEventSource.Log.TryScopeEnterEvent("SqlDataReader.TryReadInternal | API | Object Id {0}", ObjectID);
RuntimeHelpers.PrepareConstrainedRegions();

try
{
statistics = SqlStatistics.StartTimer(Statistics);
Expand Down Expand Up @@ -3561,6 +3563,36 @@ private bool TryReadInternal(bool setTimeout, out bool more)

return true;
}
catch (System.OutOfMemoryException e)
{
_isClosed = true;
SqlConnection con = _connection;
if (con != null)
{
con.Abort(e);
}
throw;
}
catch (System.StackOverflowException e)
{
_isClosed = true;
SqlConnection con = _connection;
if (con != null)
{
con.Abort(e);
}
throw;
}
catch (System.Threading.ThreadAbortException e)
{
_isClosed = true;
SqlConnection con = _connection;
if (con != null)
{
con.Abort(e);
}
throw;
}
finally
{
SqlStatistics.StopTimer(statistics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,10 @@ public void Rollback(SinglePhaseEnlistment enlistment)
connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Rollback, null, System.Data.IsolationLevel.Unspecified, _internalTransaction, true);
}
}
catch (SqlException)
catch (SqlException e)
{
ADP.TraceExceptionWithoutRethrow(e);

// Doom the connection, to make sure that the transaction is
// eventually rolled back.
// VSTS 144562: doom the connection while having the lock on it to prevent race condition with "Transaction Ended" Event
Expand All @@ -273,8 +275,9 @@ public void Rollback(SinglePhaseEnlistment enlistment)
// we have the tracing that we're doing to fallback on for the
// investigation.
}
catch (InvalidOperationException)
catch (InvalidOperationException e)
{
ADP.TraceExceptionWithoutRethrow(e);
connection.DoomThisConnection();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ bool isDelegateControlRequest
}
else if (internalTransaction.OpenResultsCount != 0)
{
//throw SQL.CannotCompleteDelegatedTransactionWithOpenResults(this);
throw SQL.CannotCompleteDelegatedTransactionWithOpenResults(this, _parser.MARSOn);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,13 @@ internal static Exception SqlDependencyNoMatchingServerDatabaseStart()
//
// SQL.SqlDelegatedTransaction
//
static internal Exception CannotCompleteDelegatedTransactionWithOpenResults(SqlInternalConnectionTds internalConnection, bool marsOn)
{
SqlErrorCollection errors = new SqlErrorCollection();
errors.Add(new SqlError(TdsEnums.TIMEOUT_EXPIRED, (byte)0x00, TdsEnums.MIN_ERROR_CLASS, null, (StringsHelper.GetString(Strings.ADP_OpenReaderExists, marsOn ? ADP.Command : ADP.Connection)), "", 0, TdsEnums.SNI_WAIT_TIMEOUT));
return SqlException.CreateException(errors, null, internalConnection);
}

internal static TransactionPromotionException PromotionFailed(Exception inner)
{
TransactionPromotionException e = new TransactionPromotionException(System.StringsHelper.GetString(Strings.SqlDelegatedTransaction_PromotionFailed), inner);
Expand Down