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

Throw an DistributedLockTimeoutException when acquire lock fail in timeout #324

Open
Luce-Florian opened this issue Sep 14, 2023 · 0 comments

Comments

@Luce-Florian
Copy link

Luce-Florian commented Sep 14, 2023

Hey,

The current implementation of the PostgreSqlDistributedLock throw a custom exception PostgreSqlDistributedLockException when the resource can't be locked before the timeout.

Short story, we use the public API AcquireDistributedLock in a custom filter to "debounce" multiple jobs that reference the same key, i recently migrate from sql server to postgre sql and i detect a regression in this part of my system.

But we have detect another side effect of the current implementation in the internal use of AcquireDistributedLock in the Hangfire.Core. The DelayedJobScheduler catch the normed DistributedLockTimeoutException to retry automaticly if the resource 'hangfire:lock:schedulepoller' can't be lock before the timeout, with the current implementation of postgre provider this part falls in error.

For moment i used this versions in my production code but the problem keep present with last version of this two projects.
Hangfire.Core : 1.7.36
Hangire.PostGre : 1.19.3

Solution :

I propose to rework PostgreSqlDistributedLock to throw DistributedLockTimeoutException when the resource can't be lock before timeout and continue to throw PostgreSqlDistributedLock for other error.

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

No branches or pull requests

1 participant