Closed dermeister0 closed 7 years ago
The problem code is in Dequeue method:
_storage.UseConnection(connection =>
{
fetchedJob = connection.Query<FetchedJob>(
fetchNextJobSqlTemplate,
new { queues = queues, fetchedAt = DateTime.UtcNow })
.SingleOrDefault();
if (fetchedJob == null)
{
cancellationToken.WaitHandle.WaitOne(_options.QueuePollInterval);
cancellationToken.ThrowIfCancellationRequested();
}
else
{
// update
connection.Execute(dequeueJobSqlTemplate,
new { id = fetchedJob.Id, fetchedAt = DateTime.UtcNow });
}
}, true);
Correct lock handling:
_storage.UseConnection(connection =>
{
fetchedJob = connection.Query<FetchedJob>(
fetchNextJobSqlTemplate,
new { queues = queues, fetchedAt = DateTime.UtcNow })
.SingleOrDefault();
}, true);
if (fetchedJob == null)
{
cancellationToken.WaitHandle.WaitOne(_options.QueuePollInterval);
cancellationToken.ThrowIfCancellationRequested();
}
else
{
_storage.UseConnection(connection =>
{
// update
connection.Execute(dequeueJobSqlTemplate,
new { id = fetchedJob.Id, fetchedAt = DateTime.UtcNow });
}, true);
}
Version 1.2.0 is now available,please update nuget reference to retry
It's fixed. Thanks!
My workers crash every time:
Not sure if it happens due to my code (I integrated Hangfire to ASP.NET Core, but used Hangfire.SQLite without changes).