Don't start transactions for migration

It looks like transactions are used internally during migration.
This commit is contained in:
Dean Herbert
2018-05-29 10:59:39 +09:00
parent a3287b8cf2
commit 80806be047
4 changed files with 11 additions and 9 deletions

View File

@ -41,17 +41,18 @@ namespace osu.Game.Database
/// Request a context for write usage. Can be consumed in a nested fashion (and will return the same underlying context).
/// This method may block if a write is already active on a different thread.
/// </summary>
/// <param name="withTransaction">Whether to start a transaction for this write.</param>
/// <returns>A usage containing a usable context.</returns>
public DatabaseWriteUsage GetForWrite()
public DatabaseWriteUsage GetForWrite(bool withTransaction = true)
{
Monitor.Enter(writeLock);
if (currentWriteTransaction == null)
if (currentWriteTransaction == null && withTransaction)
currentWriteTransaction = threadContexts.Value.Database.BeginTransaction();
Interlocked.Increment(ref currentWriteUsages);
return new DatabaseWriteUsage(threadContexts.Value, usageCompleted) { IsTransactionLeader = currentWriteUsages == 1 };
return new DatabaseWriteUsage(threadContexts.Value, usageCompleted) { IsTransactionLeader = currentWriteTransaction != null && currentWriteUsages == 1 };
}
private void usageCompleted(DatabaseWriteUsage usage)
@ -66,9 +67,9 @@ namespace osu.Game.Database
if (usages > 0) return;
if (currentWriteDidError)
currentWriteTransaction.Rollback();
currentWriteTransaction?.Rollback();
else
currentWriteTransaction.Commit();
currentWriteTransaction?.Commit();
currentWriteTransaction = null;
currentWriteDidWrite = false;