Skip to content

Commit 0bb7fe1

Browse files
authored
Merge pull request #1133 from progressonderwijs/tc/optionally_clear_pools
Tc/optionally clear pools
2 parents 3441c33 + 9343048 commit 0bb7fe1

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
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)

src/ProgressOnderwijsUtils/ProgressOnderwijsUtils.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="..\NugetPackagesCommon.props" />
33
<PropertyGroup Label="Configuration">
4-
<Version>105.2.6</Version>
5-
<PackageReleaseNotes>Bump versions.</PackageReleaseNotes>
4+
<Version>105.3.0</Version>
5+
<PackageReleaseNotes>Allow for clearing of connection pool after killing spids.</PackageReleaseNotes>
66
<Title>ProgressOnderwijsUtils</Title>
77
<Description>Collection of utilities developed by ProgressOnderwijs</Description>
88
<PackageTags>ProgressOnderwijs</PackageTags>

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)