Fix recycling never being performed due to incorrect ordering

This commit is contained in:
Dean Herbert 2018-05-30 13:37:52 +09:00
parent 31ab6f2408
commit e23e2bd348

View File

@ -64,24 +64,25 @@ namespace osu.Game.Database
currentWriteDidWrite |= usage.PerformedWrite; currentWriteDidWrite |= usage.PerformedWrite;
currentWriteDidError |= usage.Errors.Any(); currentWriteDidError |= usage.Errors.Any();
if (usages > 0) return; if (usages == 0)
if (currentWriteDidError)
currentWriteTransaction?.Rollback();
else
currentWriteTransaction?.Commit();
currentWriteTransaction = null;
currentWriteDidWrite = false;
currentWriteDidError = false;
if (currentWriteDidWrite)
{ {
// explicitly dispose to ensure any outstanding flushes happen as soon as possible (and underlying resources are purged). if (currentWriteDidError)
usage.Context.Dispose(); currentWriteTransaction?.Rollback();
else
currentWriteTransaction?.Commit();
// once all writes are complete, we want to refresh thread-specific contexts to make sure they don't have stale local caches. if (currentWriteDidWrite || currentWriteDidError)
recycleThreadContexts(); {
// explicitly dispose to ensure any outstanding flushes happen as soon as possible (and underlying resources are purged).
usage.Context.Dispose();
// once all writes are complete, we want to refresh thread-specific contexts to make sure they don't have stale local caches.
recycleThreadContexts();
}
currentWriteTransaction = null;
currentWriteDidWrite = false;
currentWriteDidError = false;
} }
} }
finally finally