fix db locking errors

This commit is contained in:
Luke Pulverenti
2016-12-11 00:12:00 -05:00
parent 0c2489059d
commit a9a808a9c4
12 changed files with 310 additions and 217 deletions

View File

@@ -188,9 +188,9 @@ namespace Emby.Server.Implementations.Data
{
cancellationToken.ThrowIfCancellationRequested();
using (var connection = CreateConnection())
lock (WriteLock)
{
using (WriteLock.Write())
using (var connection = CreateConnection())
{
connection.RunInTransaction(db =>
{
@@ -259,9 +259,9 @@ namespace Emby.Server.Implementations.Data
{
cancellationToken.ThrowIfCancellationRequested();
using (var connection = CreateConnection())
lock (WriteLock)
{
using (WriteLock.Write())
using (var connection = CreateConnection())
{
connection.RunInTransaction(db =>
{
@@ -296,9 +296,9 @@ namespace Emby.Server.Implementations.Data
throw new ArgumentNullException("key");
}
using (var connection = CreateConnection(true))
lock (WriteLock)
{
using (WriteLock.Read())
using (var connection = CreateConnection(true))
{
using (var statement = connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key =@Key and userId=@UserId"))
{
@@ -349,9 +349,9 @@ namespace Emby.Server.Implementations.Data
var list = new List<UserItemData>();
using (var connection = CreateConnection())
lock (WriteLock)
{
using (WriteLock.Read())
using (var connection = CreateConnection())
{
using (var statement = connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=@UserId"))
{