Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c784c7f
Remove CER from sqlbulkcopy
benrr101 Jul 29, 2025
224ddf6
Remove CER from SqlDataReader
benrr101 Jul 29, 2025
7e1ff6d
Remove CER from SqlDependency?
benrr101 Jul 29, 2025
e997f8d
Remove CER From WaitHandleDbConnectionPool
benrr101 Jul 29, 2025
849d49a
Remove CER from SqlTransaction
benrr101 Jul 29, 2025
453a1bc
Remove CER from SqlUtil
benrr101 Jul 29, 2025
2369226
Remove CER from SniNativeWrapper
benrr101 Jul 29, 2025
0a943ad
Remove CER from netcore SqlCommand
benrr101 Jul 29, 2025
1d2ac05
Remove CER from SqlConnection (netcore) and SqlCommandBuilder
benrr101 Jul 29, 2025
c4cfb0b
Remove CER from SqlDelegatedTransaction
benrr101 Jul 29, 2025
cf11b5c
Remove CER from SqlInternalConnection
benrr101 Jul 29, 2025
b093c7e
Remove CER from SqlInternalConnectionTds
benrr101 Jul 29, 2025
7c8cdd8
Remove CER from TdsParser (netcore)
benrr101 Jul 29, 2025
42d37b6
Remove CER from TdsParserStateObject (netcore)
benrr101 Jul 29, 2025
7988457
Remove CER from TdsParserStateObjectNative and LocalDbApi
benrr101 Jul 29, 2025
e36a480
Remove CER from SqlCommand
benrr101 Jul 29, 2025
ba42912
Remove CER from SqlConnection
benrr101 Jul 29, 2025
d7fccff
Remove CER from SqlInternalConnectionTds.cs and SqlDependencyListener.cs
benrr101 Jul 29, 2025
b88fb55
Cleanup the rest of CER
benrr101 Jul 29, 2025
6770634
Removing the last batches of CER exception stuff
benrr101 Jul 29, 2025
b1e2386
Merge branch 'main' into dev/russellben/remove-cer
benrr101 Aug 5, 2025
e56ca8c
Merge branch 'main' into dev/russellben/remove-cer
benrr101 Aug 19, 2025
3f29a69
Add comments that indicate where CER exception handling was removed
benrr101 Aug 22, 2025
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 @@ -1411,18 +1411,7 @@ private void BeginExecuteNonQueryInternalReadStage(TaskCompletionSource<object>
CachedAsyncState.SetActiveConnectionAndResult(completion, nameof(EndExecuteNonQuery), _activeConnection);
_stateObj.ReadSni(completion);
}
// Cause of a possible unstable runtime situation on facing with `OutOfMemoryException` and `StackOverflowException` exceptions,
// trying to call further functions in the catch of either may fail that should be considered on debuging!
catch (System.OutOfMemoryException e)
{
_activeConnection.Abort(e);
throw;
}
catch (System.StackOverflowException e)
{
_activeConnection.Abort(e);
throw;
}
// @TODO: CER Exception Handling was removed here (see GH#3581)
catch (Exception)
{
// Similarly, if an exception occurs put the stateObj back into the pool.
Expand Down Expand Up @@ -1968,20 +1957,7 @@ private void BeginExecuteXmlReaderInternalReadStage(TaskCompletionSource<object>
CachedAsyncState.SetActiveConnectionAndResult(completion, nameof(EndExecuteXmlReader), _activeConnection);
_stateObj.ReadSni(completion);
}
// Cause of a possible unstable runtime situation on facing with `OutOfMemoryException` and `StackOverflowException` exceptions,
// trying to call further functions in the catch of either may fail that should be considered on debuging!
catch (System.OutOfMemoryException e)
{
_activeConnection.Abort(e);
completion.TrySetException(e);
throw;
}
catch (System.StackOverflowException e)
{
_activeConnection.Abort(e);
completion.TrySetException(e);
throw;
}
// @TODO: CER Exception Handling was removed here (see GH#3581)
catch (Exception e)
{
// Similarly, if an exception occurs put the stateObj back into the pool.
Expand Down Expand Up @@ -2633,20 +2609,7 @@ private void BeginExecuteReaderInternalReadStage(TaskCompletionSource<object> co
CachedAsyncState.SetActiveConnectionAndResult(completion, nameof(EndExecuteReader), _activeConnection);
_stateObj.ReadSni(completion);
}
// Cause of a possible unstable runtime situation on facing with `OutOfMemoryException` and `StackOverflowException` exceptions,
// trying to call further functions in the catch of either may fail that should be considered on debuging!
catch (System.OutOfMemoryException e)
{
_activeConnection.Abort(e);
completion.TrySetException(e);
throw;
}
catch (System.StackOverflowException e)
{
_activeConnection.Abort(e);
completion.TrySetException(e);
throw;
}
// @TODO: CER Exception Handling was removed here (see GH#3581)
catch (Exception e)
{
// Similarly, if an exception occurs put the stateObj back into the pool.
Expand Down Expand Up @@ -4114,9 +4077,7 @@ private SqlDataReader GetParameterEncryptionDataReader(out Task returnTask, Task
SqlCommand command = (SqlCommand)state;
bool processFinallyBlockAsync = true;
bool decrementAsyncCountInFinallyBlockAsync = true;
#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif

try
{
// Check for any exceptions on network write, before reading.
Expand Down Expand Up @@ -4187,10 +4148,7 @@ private SqlDataReader GetParameterEncryptionDataReaderAsync(out Task returnTask,
{
bool processFinallyBlockAsync = true;
bool decrementAsyncCountInFinallyBlockAsync = true;

#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif

try
{
// Check for any exceptions on network write, before reading.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1237,35 +1237,13 @@ public override void ChangeDatabase(string database)
SqlStatistics statistics = null;
RepairInnerConnection();
SqlClientEventSource.Log.TryCorrelationTraceEvent("SqlConnection.ChangeDatabase | API | Correlation | Object Id {0}, Activity Id {1}, Database {2}", ObjectID, ActivityCorrelator.Current, database);
TdsParser bestEffortCleanupTarget = null;

#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif

try
{
bestEffortCleanupTarget = SqlInternalConnection.GetBestEffortCleanupTarget(this);
statistics = SqlStatistics.StartTimer(Statistics);
InnerConnection.ChangeDatabase(database);
}
catch (System.OutOfMemoryException e)
{
Abort(e);
throw;
}
catch (System.StackOverflowException e)
{
Abort(e);
throw;
}
catch (System.Threading.ThreadAbortException e)
{
Abort(e);
#if NETFRAMEWORK
SqlInternalConnection.BestEffortCleanup(bestEffortCleanupTarget);
#endif
throw;
}
// @TODO: CER Exception Handling was removed here (see GH#3581)
finally
{
SqlStatistics.StopTimer(statistics);
Expand Down Expand Up @@ -1328,15 +1306,10 @@ public override void Close()
}

SqlStatistics statistics = null;
TdsParser bestEffortCleanupTarget = null;
Exception e = null;

#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif

try
{
bestEffortCleanupTarget = SqlInternalConnection.GetBestEffortCleanupTarget(this);
statistics = SqlStatistics.StartTimer(Statistics);

Task reconnectTask = _currentReconnectionTask;
Expand All @@ -1362,27 +1335,7 @@ public override void Close()
_statistics._closeTimestamp = ADP.TimerCurrent();
}
}
catch (System.OutOfMemoryException ex)
{
e = ex;
Abort(ex);
throw;
}
catch (System.StackOverflowException ex)
{
e = ex;
Abort(ex);
throw;
}
catch (System.Threading.ThreadAbortException ex)
{
e = ex;
Abort(ex);
#if NETFRAMEWORK
SqlInternalConnection.BestEffortCleanup(bestEffortCleanupTarget);
#endif
throw;
}
// @TODO: CER Exception Handling was removed here (see GH#3581)
catch (Exception ex)
{
e = ex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,6 @@ internal SqlInternalConnectionTds(
_parserLock.Wait(canReleaseFromAnyThread: false);
ThreadHasParserLockForClose = true; // In case of error, let ourselves know that we already own the parser lock

#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
_timeout = TimeoutTimer.StartSecondsTimeout(connectionOptions.ConnectTimeout);
Expand Down Expand Up @@ -573,21 +570,7 @@ internal SqlInternalConnectionTds(
}
}
}
catch (System.OutOfMemoryException)
{
DoomThisConnection();
throw;
}
catch (System.StackOverflowException)
{
DoomThisConnection();
throw;
}
catch (System.Threading.ThreadAbortException)
{
DoomThisConnection();
throw;
}
// @TODO: CER Exception Handling was removed here (see GH#3581)
finally
{
ThreadHasParserLockForClose = false;
Expand Down Expand Up @@ -2136,39 +2119,19 @@ internal bool GetSessionAndReconnectIfNeeded(SqlConnection parent, int timeout =

try
{
#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
Task reconnectTask = parent.ValidateAndReconnect(() =>
{
Task reconnectTask = parent.ValidateAndReconnect(() =>
{
ThreadHasParserLockForClose = false;
_parserLock.Release();
releaseConnectionLock = false;
}, timeout);
if (reconnectTask != null)
{
AsyncHelper.WaitForCompletion(reconnectTask, timeout);
return true;
}
return false;
}
catch (System.OutOfMemoryException)
{
DoomThisConnection();
throw;
}
catch (System.StackOverflowException)
{
DoomThisConnection();
throw;
}
catch (System.Threading.ThreadAbortException)
ThreadHasParserLockForClose = false;
_parserLock.Release();
releaseConnectionLock = false;
}, timeout);
if (reconnectTask != null)
{
DoomThisConnection();
throw;
AsyncHelper.WaitForCompletion(reconnectTask, timeout);
return true;
}
return false;
// @TODO: CER Exception Handling was removed here (see GH#3581)
}
finally
{
Expand Down Expand Up @@ -2475,10 +2438,6 @@ internal bool TryGetFedAuthTokenLocked(SqlFedAuthInfo fedAuthInfo, DbConnectionP
// Variable which indicates if we did indeed manage to acquire the lock on the authentication context, to try update it.
bool authenticationContextLocked = false;

// Prepare CER to ensure the lock on authentication context is released.
#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
// Try to obtain a lock on the context. If acquired, this thread got the opportunity to update.
Expand Down
Loading
Loading