From 7a60a5e4999e19115a2d8e144e8afe48ceb8b808 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 25 Feb 2017 10:39:13 +0900 Subject: [PATCH] Lock the BeatmapDatabase's connection during imports. This should avoid any potential issues with intertwined transactions on the same connection while still allowing higher throughput when importing. --- osu.Game/Database/BeatmapDatabase.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 66c348279d..ff58031c57 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -181,15 +181,18 @@ namespace osu.Game.Database public void Import(IEnumerable beatmapSets) { - connection.BeginTransaction(); - - foreach (var s in beatmapSets) + lock (connection) { - connection.InsertWithChildren(s, true); - BeatmapSetAdded?.Invoke(s); - } + connection.BeginTransaction(); - connection.Commit(); + foreach (var s in beatmapSets) + { + connection.InsertWithChildren(s, true); + BeatmapSetAdded?.Invoke(s); + } + + connection.Commit(); + } } public void Delete(BeatmapSetInfo beatmapSet)