Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LT-5770: [Trading Core] Potential Deduplication Lock Failure #560

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lykke-vashetsin
Copy link

No description provided.

Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
MarginTrading.Backend.Core 66% 59% 1518
MarginTrading.Common 18% 18% 378
MarginTrading.Backend.Contracts 31% 25% 620
MarginTrading.Backend.Core.Mappers 0% 0% 4
MarginTrading.AzureRepositories 4% 36% 197
MarginTrading.Backend 8% 14% 666
MarginTrading.Backend.Services 43% 39% 3294
MarginTrading.SqlRepositories 0% 0% 471
Summary 37% (6017 / 16430) 35% (1527 / 4327) 7148

@@ -47,7 +45,7 @@ public StartupDeduplicationService(
/// But the probability of such situation is extremely small, so current implementation neglects it.
/// In case if it is required to assure safety in clustered/replicated mode RedLock algorithm may be used.
/// </summary>
public void HoldLock()
public void HoldLock(CancellationTokenSource cancellationTokenSource)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to clarify you better call it hostRunCancellationToken or something similar.

@@ -79,15 +73,13 @@ await _database.LockExtendAsync(LockKey, _lockValue,
}
catch (Exception exception)
{
workerException = exception;
_cancellationTokenSource.Cancel();
cancellationTokenSource.Cancel();
}
});
}

public void Dispose()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you still need deduplication service to implement Idisposable interface?

@@ -79,15 +73,13 @@ await _database.LockExtendAsync(LockKey, _lockValue,
}
catch (Exception exception)
{
workerException = exception;
_cancellationTokenSource.Cancel();
cancellationTokenSource.Cancel();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imagine trading core started normally and processing requests. After an hour the redis is not available for some reason or just failed to extend the lock. This probably will lead to trading core app termination and attempt to immediately restart which is not acceptable.

}
catch (Exception e)
{
CancellationTokenSource.Dispose();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if CancellationTokenSource is null here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need StartupDeduplicationService still to implement IDisposable interface?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants