Ensure score submission completion before notifying spectator server when exiting play early #21753
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a
SubmittingPlayer
gameplay session ends with the successful completion of a beatmap,PrepareScoreForResultsAsync()
ensures that the score submission request is sent to and responded to byosu-web
before callingISpectatorClient.EndPlaying()
:osu/osu.Game/Screens/Play/SubmittingPlayer.cs
Lines 132 to 133 in b09c00d
While previously this was mostly an implementation detail, this becomes important when considering that more and more server-side flows (replay upload, notifying about score processing completion) hook into
EndPlaying()
, and assume that by the point that message arrives atosu-spectator-server
, the score has already been submitted and has been assigned a score ID that corresponds to the score submission token.As it turns out, in the early-exit path (when the user exits the play midway through, retries, or just fails), the same ordering guarantees were not provided. The score's submission ran concurrently to the spectator client
EndPlaying()
call, therefore creating a network race (note the lack ofawait
):osu/osu.Game/Screens/Play/SubmittingPlayer.cs
Lines 161 to 162 in b09c00d
osu-server-spectator
components that implciitly relied on the ordering provided by the happy path, could therefore fail to unmap the score submission token to a score ID.Note that as written, the
osu-server-spectator
replay upload flow is not really affected by this, as it self-corrects by essentially polling the database and trying to unmap the score submission token to a score ID for up to 30 seconds. However, this change would have the benefit of reducing the polls required in such cases to just one DB retrieval.This change aims to bring both paths to parity by waiting for the score submission request even when early-exiting the player instance.
I considered adding test coverage for the ordering but it's not instantly doable. I'll do it on request if this is deemed to be the correct direction and test coverage is deemed required.