Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.4.1 #66

Merged
merged 23 commits into from
Feb 5, 2024
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
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
6 changes: 3 additions & 3 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
runs-on: ${{matrix.os}}

steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v1.7.2
uses: actions/setup-dotnet@v3
with:
dotnet-version: 2.2.108
dotnet-version: 6.0.x
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Unit Tests
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,5 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/
*.db
/src/samples/WebSample/Hangfire.db-shm
/src/samples/WebSample/Hangfire.db-wal
24 changes: 12 additions & 12 deletions Hangfire.Storage.SQLite.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29424.173
# Visual Studio Version 17
VisualStudioVersion = 17.2.32602.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hangfire.Storage.SQLite", "src\main\Hangfire.Storage.SQLite\Hangfire.Storage.SQLite.csproj", "{27A56CA6-6B11-4D43-8BF8-F9AF5907556C}"
EndProject
Expand All @@ -14,9 +14,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.github\workflows\dotnetcore.yml = .github\workflows\dotnetcore.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSample", "src\samples\ConsoleSample\ConsoleSample.csproj", "{453B460B-6643-4EBC-A046-3BDA69EFF2CE}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebSample", "src\samples\WebSample\WebSample.csproj", "{7170DD33-D6CA-40A5-AA03-D96DE74BA353}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebSample", "src\samples\WebSample\WebSample.csproj", "{1ABCB458-08C4-4132-8295-A5A605F6B75F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSample", "src\samples\ConsoleSample\ConsoleSample.csproj", "{C2137C38-9AE6-4200-9F97-E3DA5A2DC741}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -32,14 +32,14 @@ Global
{279C04FC-22EB-438C-9BF7-2CBA306025F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{279C04FC-22EB-438C-9BF7-2CBA306025F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{279C04FC-22EB-438C-9BF7-2CBA306025F7}.Release|Any CPU.Build.0 = Release|Any CPU
{453B460B-6643-4EBC-A046-3BDA69EFF2CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{453B460B-6643-4EBC-A046-3BDA69EFF2CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{453B460B-6643-4EBC-A046-3BDA69EFF2CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{453B460B-6643-4EBC-A046-3BDA69EFF2CE}.Release|Any CPU.Build.0 = Release|Any CPU
{1ABCB458-08C4-4132-8295-A5A605F6B75F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1ABCB458-08C4-4132-8295-A5A605F6B75F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1ABCB458-08C4-4132-8295-A5A605F6B75F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1ABCB458-08C4-4132-8295-A5A605F6B75F}.Release|Any CPU.Build.0 = Release|Any CPU
{7170DD33-D6CA-40A5-AA03-D96DE74BA353}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7170DD33-D6CA-40A5-AA03-D96DE74BA353}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7170DD33-D6CA-40A5-AA03-D96DE74BA353}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7170DD33-D6CA-40A5-AA03-D96DE74BA353}.Release|Any CPU.Build.0 = Release|Any CPU
{C2137C38-9AE6-4200-9F97-E3DA5A2DC741}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2137C38-9AE6-4200-9F97-E3DA5A2DC741}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2137C38-9AE6-4200-9F97-E3DA5A2DC741}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2137C38-9AE6-4200-9F97-E3DA5A2DC741}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
18 changes: 11 additions & 7 deletions src/main/Hangfire.Storage.SQLite/CountersAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using Hangfire.Logging;
using Hangfire.Server;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Hangfire.Storage.SQLite.Entities;

Expand All @@ -13,9 +11,9 @@ namespace Hangfire.Storage.SQLite
/// <summary>
/// Represents Counter collection aggregator for SQLite database
/// </summary>
#pragma warning disable CS0618
#pragma warning disable CS0618
public class CountersAggregator : IBackgroundProcess, IServerComponent
#pragma warning restore CS0618
#pragma warning restore CS0618
{
private static readonly ILog Logger = LogProvider.For<CountersAggregator>();
private const int NumberOfRecordsInSinglePass = 1000;
Expand Down Expand Up @@ -50,11 +48,17 @@ public void Execute([NotNull] BackgroundProcessContext context)
/// </summary>
/// <param name="cancellationToken">Cancellation token</param>
public void Execute(CancellationToken cancellationToken)
{
// DANIEL WAS HERE
Retry.Twice((_) => _Execute(cancellationToken));
}

private void _Execute(CancellationToken cancellationToken)
{
Logger.DebugFormat("Aggregating records in 'Counter' table...");

long removedCount = 0;

do
{
using (var storageConnection = (HangfireSQLiteConnection)_storage.GetConnection())
Expand Down Expand Up @@ -97,7 +101,7 @@ public void Execute(CancellationToken cancellationToken)
counter.Value += item.Value;
counter.ExpireAt = item.ExpireAt > aggregatedItem.ExpireAt
? (item.ExpireAt > DateTime.MinValue ? item.ExpireAt : DateTime.MinValue)
: (aggregatedItem.ExpireAt > DateTime.MinValue ?
: (aggregatedItem.ExpireAt > DateTime.MinValue ?
aggregatedItem.ExpireAt : DateTime.MinValue);
storageDb.Database.Update(counter);
}
Expand Down Expand Up @@ -134,4 +138,4 @@ public override string ToString()
return "SQLite Counter Collection Aggregator";
}
}
}
}
24 changes: 13 additions & 11 deletions src/main/Hangfire.Storage.SQLite/ExpirationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,22 @@ public void Execute([NotNull] BackgroundProcessContext context)
/// <param name="cancellationToken">Cancellation token</param>
public void Execute(CancellationToken cancellationToken)
{
HangfireDbContext connection = _storage.CreateAndOpenConnection();
var storageConnection = connection.StorageOptions;

foreach (var table in ProcessedTables)
using (HangfireDbContext connection = _storage.CreateAndOpenConnection())
{
Logger.Info($"Removing outdated records from the '{table}' table...");
var storageConnection = connection.StorageOptions;

int affected;
do
foreach (var table in ProcessedTables)
{
affected = RemoveExpireRows(connection, table);
} while (affected == NumberOfRecordsInSinglePass);
Logger.Info($"Removing outdated records from the '{table}' table...");

int affected;
do
{
affected = RemoveExpireRows(connection, table);
} while (affected == NumberOfRecordsInSinglePass);

Logger.Info($"Outdated records removed from the '{table}' table...");
Logger.Info($"Outdated records removed from the '{table}' table...");
}
}

cancellationToken.WaitHandle.WaitOne(_checkInterval);
Expand Down Expand Up @@ -128,4 +130,4 @@ private int RemoveExpireRows(HangfireDbContext db, string table)
return rowsAffected;
}
}
}
}
11 changes: 5 additions & 6 deletions src/main/Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TargetFrameworks>netstandard2.0;net48</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<Version>0.3.4</Version>
<Version>0.4.1</Version>
<Authors>RaisedApp</Authors>
<Company>RaisedApp</Company>
<Copyright>Copyright © 2019 - Present</Copyright>
Expand All @@ -20,8 +20,8 @@
<title>Hangfire Storage SQLite</title>
<Description>An Alternative SQLite Storage for Hangfire</Description>
<PackageReleaseNotes>
0.3.4
- Bug Fix (GetTimelineStats and GetHourlyTimelineStats return wrongly matched results), thanks to @MaxTheWhale
0.4.1
- Stability and retry enhancements introduced by: Daniel Lindblom
</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
Expand All @@ -31,9 +31,8 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Hangfire.Core" Version="1.7.6" />
<PackageReference Condition="'$(TargetFramework)' == 'net45'" Include="sqlite-net-pcl" Version="1.6.292" />
<PackageReference Condition="'$(TargetFramework)' != 'net45'" Include="sqlite-net-pcl" Version="1.7.335" />
<PackageReference Include="Hangfire.Core" Version="1.8.0" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
</ItemGroup>

</Project>
Loading
Loading