Skip to content
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 @@ -219,15 +219,6 @@ internal void Activate()
_transactionState = TransactionState.Active;
}

private void DoomConnectionNoReuse(SqlInternalConnection innerConnection)
{
if (null != innerConnection)
{
innerConnection.DoNotPoolThisConnection();
innerConnection.DoomThisConnection();
}
}

private void CheckTransactionLevelAndZombie()
{
try
Expand Down Expand Up @@ -298,11 +289,6 @@ internal void Commit()
}
catch (Exception e)
{
// GitHub Issue #130 - When an exception has occurred on transaction completion request,
// this connection may not be in reusable state.
// We will doom this connection and make sure it does not go back to the pool.
DoomConnectionNoReuse(_innerConnection);

if (ADP.IsCatchableExceptionType(e))
{
CheckTransactionLevelAndZombie();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
Expand Down Expand Up @@ -140,6 +141,19 @@ override public void Commit()

_internalTransaction.Commit();
}
catch (SqlException ex)
{
// GitHub Issue #130 - When a timeout exception has occurred on transaction completion request,
// this connection may not be in reusable state.
// We will abort this connection and make sure it does not go back to the pool.
var innerException = ex.InnerException as Win32Exception;
if (innerException != null && innerException.NativeErrorCode == TdsEnums.SNI_WAIT_TIMEOUT)
{
_connection.Abort(ex);
}
e = ex;
throw;
}
catch (Exception ex)
{
e = ex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
Expand Down Expand Up @@ -188,6 +189,18 @@ override public void Commit()
SqlInternalConnection.BestEffortCleanup(bestEffortCleanupTarget);
throw;
}
catch (SqlException e)
{
// GitHub Issue #130 - When a timeout exception has occurred on transaction completion request,
// this connection may not be in reusable state.
// We will abort this connection and make sure it does not go back to the pool.
var innerException = e.InnerException as Win32Exception;
if (innerException != null && innerException.NativeErrorCode == TdsEnums.SNI_WAIT_TIMEOUT)
{
_connection.Abort(e);
}
throw;
}
finally
{
_isFromAPI = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,6 @@ internal void Activate()
_transactionState = TransactionState.Active;
}

private void DoomConnectionNoReuse(SqlInternalConnection innerConnection)
{
if (null != innerConnection)
{
innerConnection.DoNotPoolThisConnection();
innerConnection.DoomThisConnection();
}
}

private void CheckTransactionLevelAndZombie()
{
try
Expand Down Expand Up @@ -344,11 +335,6 @@ internal void Commit()
}
catch (Exception e)
{
// GitHub Issue #130 - When an exception has occurred on transaction completion request,
// this connection may not be in reusable state.
// We will doom this connection and make sure it does not go back to the pool.
DoomConnectionNoReuse(_innerConnection);

// UNDONE - should not be catching all exceptions!!!
if (ADP.IsCatchableExceptionType(e))
{
Expand Down