This PR brings in a bunch of changes and smaller threading optimizations/fixes
Instead of passing in a SQLiteConnection, we now use a SQLiteDbConnectionFactory
this is only a Api breaking change on develop at this point in time
HangfireDbContext is now pooled by adding PooledHangfireDbContext
The Pool has an configurable Limit of, by default, 20 pooled connections (SQLiteStorageOptions.PoolSize)
The default JournalMode is now WAL as it is much better suited for concurrent access than traditional rollback journal
SQLiteMonitoringApi now uses a (pooled-)connection per call to UseConnection as the interface does not allow for Disposing, thus would leak Connections otherwise.
ExpirationManager uses a pooled connection per Execute
SQLiteDistributedLock & SQLiteWriteOnlyTransaction re-throw exceptions without discarding the Stacktrace (throw ex; -> throw;)
Tests:
Concurrent Tests now use a Connection per Thread, to resemble the expected use of the library.
Hangfire always grabs a connection using Get(ReadOnly)Connection and disposes it in a per-execution basis, it doesn't share the connection with multiple threads.
Added a bunch of using-statements
Tests now mostly use storage.GetConnection or storage.CreateAndOpenConnection()
SQLiteDistributedLockFacts.Ctor_WaitForLock_SignaledAtLockRelease now uses a ManualResetEventSlim to signal a taken lock instead of randomly waiting for a second and just assuming that the lock was taken.
This PR brings in a bunch of changes and smaller threading optimizations/fixes
SQLiteConnection
, we now use aSQLiteDbConnectionFactory
HangfireDbContext
is now pooled by addingPooledHangfireDbContext
20
pooled connections (SQLiteStorageOptions.PoolSize
)JournalMode
is nowWAL
as it is much better suited for concurrent access than traditional rollback journalSQLiteMonitoringApi
now uses a (pooled-)connection per call toUseConnection
as the interface does not allow for Disposing, thus would leak Connections otherwise.ExpirationManager
uses a pooled connection perExecute
SQLiteDistributedLock
&SQLiteWriteOnlyTransaction
re-throw exceptions without discarding the Stacktrace (throw ex;
->throw;
)Tests:
Hangfire always grabs a connection using
Get(ReadOnly)Connection
and disposes it in a per-execution basis, it doesn't share the connection with multiple threads.using
-statementsstorage.GetConnection
orstorage.CreateAndOpenConnection()
SQLiteDistributedLockFacts.Ctor_WaitForLock_SignaledAtLockRelease
now uses aManualResetEventSlim
to signal a taken lock instead of randomly waiting for a second and just assuming that the lock was taken.