codeyu / Hangfire.LiteDB

LiteDB storage for Hangfire.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scheduled job never fires

igitur opened this issue · comments

Hi,

Thanks for this project. I'm fairly new to Hangfire and all the extensions, but I noticed something. Delayed jobs don't fire when using Hangfire.LiteDB. When using Hangfire.SqlServer, there is no problem.

With some debugging, I found a discrepancy between SqlServerConnection.GetFirstByLowestScoreFromSet and LiteDbConnection.GetFirstByLowestScoreFromSet

public override string GetFirstByLowestScoreFromSet(string key, double fromScore, double toScore)
{
    if (key == null) throw new ArgumentNullException(nameof(key));
    if (toScore < fromScore) throw new ArgumentException("The `toScore` value must be higher or equal to the `fromScore` value.");

    return _storage.UseConnection(_dedicatedConnection, connection => connection.ExecuteScalar<string>(
        $@"select top 1 Value from [{_storage.SchemaName}].[Set] with (readcommittedlock) where [Key] = @key and Score between @from and @to order by Score",
        new { key, from = fromScore, to = toScore },
        commandTimeout: _storage.CommandTimeout));
}
public override string GetFirstByLowestScoreFromSet(string key, double fromScore, double toScore)
{
    if (key == null)
    {
        throw new ArgumentNullException(nameof(key));
    }

    if (toScore < fromScore)
    {
        throw new ArgumentException("The `toScore` value must be higher or equal to the `fromScore` value.");
    }

    return Database
        .StateDataSet
        .Find(_ => _.Key == key &&
                _.Score == fromScore && // discrepancy! should this be >= ?
                _.Score <= toScore)
        .OrderBy(_ => _.Score)
        .Select(_ => _.Value)
        .FirstOrDefault() as string;
}

I don't know the codebase well enough to say that the _.Score == fromScore is wrong or not.

Thanks @igitur , there are some bugs in this project that haven't been solved. So it cannot be used in a production environment. When LiteDB released 5.0, I plan to fix them. thanks again.

Thanks for your feedback. Do you have any comments on the pull request?

Wow, so after over an hour debugging the issue why my scheduled task did not fire, I should have first checked the issues section ;-).

Any chance for an update soon?