Avoid reprocessing scores which already failed an upgrade previously

Closes https://github.com/ppy/osu/issues/24301.
This commit is contained in:
Dean Herbert 2023-07-26 16:08:02 +09:00
parent c1ba8fe175
commit 30baac0f3d
3 changed files with 15 additions and 3 deletions

View File

@ -186,7 +186,7 @@ namespace osu.Game
realmAccess.Run(r =>
{
foreach (var score in r.All<ScoreInfo>())
foreach (var score in r.All<ScoreInfo>().Where(s => !s.TotalScoreUpgradeFailed))
{
if (score.BeatmapInfo != null
&& score.Statistics.Sum(kvp => kvp.Value) > 0
@ -225,6 +225,7 @@ namespace osu.Game
catch (Exception e)
{
Logger.Log(@$"Failed to populate maximum statistics for {id}: {e}");
realmAccess.Write(r => r.Find<ScoreInfo>(id)!.TotalScoreUpgradeFailed = true);
}
}
}
@ -234,7 +235,7 @@ namespace osu.Game
Logger.Log("Querying for scores that need total score conversion...");
HashSet<Guid> scoreIds = realmAccess.Run(r => new HashSet<Guid>(r.All<ScoreInfo>()
.Where(s => s.BeatmapInfo != null && s.TotalScoreVersion == 30000002)
.Where(s => !s.TotalScoreUpgradeFailed && s.BeatmapInfo != null && s.TotalScoreVersion == 30000002)
.AsEnumerable().Select(s => s.ID)));
Logger.Log($"Found {scoreIds.Count} scores which require total score conversion.");
@ -283,6 +284,7 @@ namespace osu.Game
catch (Exception e)
{
Logger.Log($"Failed to convert total score for {id}: {e}");
realmAccess.Write(r => r.Find<ScoreInfo>(id)!.TotalScoreUpgradeFailed = true);
++failedCount;
}
}

View File

@ -82,8 +82,9 @@ namespace osu.Game.Database
/// 30 2023-06-16 Run migration of old lazer scores again. This time with more correct rounding considerations.
/// 31 2023-06-26 Add Version and LegacyTotalScore to ScoreInfo, set Version to 30000002 and copy TotalScore into LegacyTotalScore for legacy scores.
/// 32 2023-07-09 Populate legacy scores with the ScoreV2 mod (and restore TotalScore to the legacy total for such scores) using replay files.
/// 33 2023-07-26 Add TotalScoreUpgradeFailed flag to ScoreInfo to track upgrade failures.
/// </summary>
private const int schema_version = 32;
private const int schema_version = 33;
/// <summary>
/// Lock object which is held during <see cref="BlockAllOperations"/> sections, blocking realm retrieval during blocking periods.

View File

@ -81,6 +81,15 @@ namespace osu.Game.Scoring
/// </remarks>
public long? LegacyTotalScore { get; set; }
/// <summary>
/// If an reprocess of total score failed to update this score to the latest version, this flag will become <c>true</c>.
/// Should be used to ensure we don't repeatedly attempt to update the same scores each startup even though we already know they will fail.
/// </summary>
/// <remarks>
/// See https://github.com/ppy/osu/issues/24301 for one example of how this can occur(missing beatmap file on disk).
/// </remarks>
public bool TotalScoreUpgradeFailed { get; set; }
public int MaxCombo { get; set; }
public double Accuracy { get; set; }