Skip to content

Commit

Permalink
Fix maxProcessableId not accounting for correct ruleset or deletion…
Browse files Browse the repository at this point in the history
… entries
  • Loading branch information
peppy committed Dec 12, 2023
1 parent 3174580 commit 95abdce
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ public async Task<int> OnExecuteAsync(CancellationToken cancellationToken)

if (singleRun)
{
// when doing a single run, we need to make sure not to run into scores which are in the process queue (to avoid
// touching them while they are still being written).
using (var db = DatabaseAccess.GetConnection())
maxProcessableId = db.QuerySingle<ulong?>("SELECT MIN(score_id) FROM score_process_queue") - 1 ?? ulong.MaxValue;
maxProcessableId = getMaxProcessable(ruleset);

where = "WHERE score_id >= @lastId AND score_id <= @maxProcessableId";
}
Expand Down Expand Up @@ -343,6 +340,21 @@ void queueNextBatch()
return 0;
}

private ulong getMaxProcessable(Ruleset ruleset)
{
try
{
// when doing a single run, we need to make sure not to run into scores which are in the process queue (to avoid
// touching them while they are still being written).
using (var db = DatabaseAccess.GetConnection())
return db.QuerySingle<ulong?>($"SELECT MIN(score_id) FROM score_process_queue WHERE is_deleted = 0 AND mode = {ruleset.RulesetInfo.OnlineID}") - 1 ?? ulong.MaxValue;
}
catch
{
return ulong.MaxValue;
}
}

private void checkSlaveLatency(MySqlConnection db)
{
long currentTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
Expand Down

0 comments on commit 95abdce

Please sign in to comment.