From 3a1feb9b5567972dfd21c3e11c42e944355583e4 Mon Sep 17 00:00:00 2001 From: Sam Cook Date: Tue, 13 Feb 2018 19:17:41 +0000 Subject: [PATCH] Log instance summary in lock start and extend methods. Move status reset during unlock to dispose method. --- RedLockNet.SERedis.Shared/RedLock.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/RedLockNet.SERedis.Shared/RedLock.cs b/RedLockNet.SERedis.Shared/RedLock.cs index 3fe1d81..56bb6cd 100644 --- a/RedLockNet.SERedis.Shared/RedLock.cs +++ b/RedLockNet.SERedis.Shared/RedLock.cs @@ -156,7 +156,7 @@ private void Start() (Status, InstanceSummary) = Acquire(); } - logger.LogInformation($"Lock status: {Status}, {Resource} ({LockId})"); + logger.LogInformation($"Lock status: {Status} ({InstanceSummary}), {Resource} ({LockId})"); if (IsAcquired) { @@ -187,7 +187,7 @@ private async Task StartAsync() (Status, InstanceSummary) = await AcquireAsync().ConfigureAwait(false); } - logger.LogInformation($"Lock status: {Status}, {Resource} ({LockId})"); + logger.LogInformation($"Lock status: {Status} ({InstanceSummary}), {Resource} ({LockId})"); if (IsAcquired) { @@ -312,14 +312,14 @@ private void StartAutoExtendTimer() InstanceSummary = extendSummary; ExtendCount++; - logger.LogDebug($"Extended lock: {Resource} ({LockId})"); + logger.LogDebug($"Extended lock, {Status} ({InstanceSummary}): {Resource} ({LockId})"); } else { Status = GetFailedRedLockStatus(extendSummary); InstanceSummary = extendSummary; - logger.LogWarning($"Failed to extend lock: {Resource} ({LockId})"); + logger.LogWarning($"Failed to extend lock, {Status} ({InstanceSummary}): {Resource} ({LockId})"); } } catch (Exception exception) @@ -379,9 +379,6 @@ private RedLockInstanceSummary Extend() private void Unlock() { Parallel.ForEach(redisCaches, UnlockInstance); - - Status = RedLockStatus.Unlocked; - InstanceSummary = new RedLockInstanceSummary(); } private async Task UnlockAsync() @@ -579,6 +576,9 @@ protected virtual void Dispose(bool disposing) Unlock(); + Status = RedLockStatus.Unlocked; + InstanceSummary = new RedLockInstanceSummary(); + isDisposed = true; }