Skip to content

Commit 36274fa

Browse files
committed
Optionally clear pool after killing processes
1 parent 3441c33 commit 36274fa

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/ProgressOnderwijsUtils/Data/SqlServerUtils.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public static class SqlServerUtils
55
/// <summary>
66
/// If the catalog in question does not exist, this method does nothing.
77
/// </summary>
8-
public static void KillOtherUserProcessesOnDb(SqlConnection sqlContext, string catalog)
8+
public static void KillOtherUserProcessesOnDb(SqlConnection sqlContext, string catalog, bool clearAllPools)
99
{
1010
try {
1111
SQL(
@@ -26,6 +26,9 @@ and s.status in ('running', 'sleeping')
2626
} catch (Exception e) when (IsSpidAlreadyDeadException(e)) {
2727
//the spid may already be dead by the time we get around to killing it, which throws an error. We ignore that error.
2828
}
29+
if (clearAllPools) {
30+
SqlConnection.ClearAllPools();
31+
}
2932
}
3033

3134
static bool IsSpidAlreadyDeadException(Exception exception)

test/ProgressOnderwijsUtils.Tests/Data/SqlServerUtilsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ public sealed class SqlServerUtilsTest : TransactedLocalConnection
44
{
55
[Fact]
66
public void KillOtherUserProcessesOnDb_works_on_non_existing_catalog()
7-
=> SqlServerUtils.KillOtherUserProcessesOnDb(Connection, nameof(KillOtherUserProcessesOnDb_works_on_non_existing_catalog));
7+
=> SqlServerUtils.KillOtherUserProcessesOnDb(Connection, nameof(KillOtherUserProcessesOnDb_works_on_non_existing_catalog), true);
88
}

0 commit comments

Comments
 (0)