mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Recycle all contexts on beginning a write operation for the time being
This commit is contained in:
parent
e23e2bd348
commit
4a7de043e0
@ -48,7 +48,14 @@ namespace osu.Game.Database
|
||||
Monitor.Enter(writeLock);
|
||||
|
||||
if (currentWriteTransaction == null && withTransaction)
|
||||
{
|
||||
// this mitigates the fact that changes on tracked entities will not be rolled back with the transaction by ensuring write operations are always executed in isolated contexts.
|
||||
// if this results in sub-optimal efficiency, we may need to look into removing Database-level transactions in favour of running SaveChanges where we currently commit the transaction.
|
||||
if (threadContexts.IsValueCreated)
|
||||
recycleThreadContexts();
|
||||
|
||||
currentWriteTransaction = threadContexts.Value.Database.BeginTransaction();
|
||||
}
|
||||
|
||||
Interlocked.Increment(ref currentWriteUsages);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user