1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:52:55 +08:00

Merge pull request #13692 from peppy/add-migration-logging

Add more logging to help diagnose realm migration failures
This commit is contained in:
Dan Balasescu 2021-06-29 21:34:08 +09:00 committed by GitHub
commit 5edaf8235d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -89,12 +89,18 @@ namespace osu.Game.Database
if (IsDisposed)
throw new ObjectDisposedException(nameof(RealmContextFactory));
Logger.Log(@"Blocking realm operations.", LoggingTarget.Database);
blockingLock.Wait();
flushContexts();
return new InvokeOnDisposal<RealmContextFactory>(this, endBlockingSection);
static void endBlockingSection(RealmContextFactory factory) => factory.blockingLock.Release();
static void endBlockingSection(RealmContextFactory factory)
{
factory.blockingLock.Release();
Logger.Log(@"Restoring realm operations.", LoggingTarget.Database);
}
}
protected override void Update()
@ -147,6 +153,8 @@ namespace osu.Game.Database
private void flushContexts()
{
Logger.Log(@"Flushing realm contexts...", LoggingTarget.Database);
var previousContext = context;
context = null;
@ -155,6 +163,8 @@ namespace osu.Game.Database
Thread.Sleep(50);
previousContext?.Dispose();
Logger.Log(@"Realm contexts flushed.", LoggingTarget.Database);
}
protected override void Dispose(bool isDisposing)

View File

@ -422,11 +422,15 @@ namespace osu.Game
public void Migrate(string path)
{
Logger.Log($@"Migrating osu! data from ""{Storage.GetFullPath(string.Empty)}"" to ""{path}""...");
using (realmFactory.BlockAllOperations())
{
contextFactory.FlushConnections();
(Storage as OsuStorage)?.Migrate(Host.GetStorage(path));
}
Logger.Log(@"Migration complete!");
}
protected override UserInputManager CreateUserInputManager() => new OsuUserInputManager();