Skip to content

Commit

Permalink
Log instance summary in lock start and extend methods.
Browse files Browse the repository at this point in the history
Move status reset during unlock to dispose method.
  • Loading branch information
samcook committed Feb 13, 2018
1 parent 217e55a commit 3a1feb9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions RedLockNet.SERedis.Shared/RedLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -379,9 +379,6 @@ private RedLockInstanceSummary Extend()
private void Unlock()
{
Parallel.ForEach(redisCaches, UnlockInstance);

Status = RedLockStatus.Unlocked;
InstanceSummary = new RedLockInstanceSummary();
}

private async Task UnlockAsync()
Expand Down Expand Up @@ -579,6 +576,9 @@ protected virtual void Dispose(bool disposing)

Unlock();

Status = RedLockStatus.Unlocked;
InstanceSummary = new RedLockInstanceSummary();

isDisposed = true;
}

Expand Down

0 comments on commit 3a1feb9

Please sign in to comment.