Skip to content

System.TimeoutException: Lock for osu.Server.Spectator.Hubs.Multiplayer.ServerMultiplayerRoom id 2614784 could not be obta... #479

@ppy-sentryintegration

Description

@ppy-sentryintegration

Sentry Issue: OSU-SERVER-SPECTATOR-RX

System.TimeoutException: Lock for osu.Server.Spectator.Hubs.Multiplayer.ServerMultiplayerRoom id 2614784 could not be obtained within timeout period
  File "Entities/EntityStore.cs", line 270, in async Task TrackedEntity.ObtainLockAsync()
  File "Entities/EntityStore.cs", line 92, in async Task<ItemUsage<T>> EntityStore<T>.GetForUse(long id, bool createOnMissing)
  File "Hubs/Multiplayer/MultiplayerHub.cs", line 530, in async Task<ItemUsage<ServerMultiplayerRoom>> MultiplayerHub.getLocalUserRoom(MultiplayerClientState state)
  File "Hubs/Multiplayer/MultiplayerHub.cs", line 241, in async Task MultiplayerHub.ChangeState(MultiplayerUserState newState)
  File "ClientVersionChecker.cs", line 53, in async ValueTask<object> ClientVersionChecker.InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object>> next)
...
(5 additional frame(s) were not displayed)

[user:38880243] Failed to invoke hub method: ChangeState(Idle)

This is caused by this 10-second delay when score retrieval fails:

using (var db = DbFactory.GetInstance())
{
// Wait up to 10 seconds to retrieve scores for all players, before continuing and giving them 0 score.
using (var cts = new CancellationTokenSource(ScoreRetrievalWaitTime))
{
SoloScore[] retrievedScores = [];
while (!cts.IsCancellationRequested)
{
retrievedScores = (await db.GetAllScoresForPlaylistItem(Room.Settings.PlaylistItemId)).ToArray();
if (retrievedScores.Length == State.Users.Count)
break;
await Task.Delay(1000, CancellationToken.None);
}
scores.AddRange(retrievedScores);
}
}

It's a longer delay than the entity store lock, which expires in 5-seconds:

private const int lock_timeout = 5000;

The tricky part here is decoupling the ranked play process from a user event, so it doesn't need to hold onto the lock.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions