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

JDBC provider - unlock logic ignores the lockedBy property #1986

Open
rshisman opened this issue Jun 20, 2024 · 1 comment
Open

JDBC provider - unlock logic ignores the lockedBy property #1986

rshisman opened this issue Jun 20, 2024 · 1 comment

Comments

@rshisman
Copy link

hi @lukas-krecan

the unlock for the JDBC provider actually updated the lockUntil property in the database:
public String getUnlockStatement() { return "UPDATE " + tableName() + " SET " + lockUntil() + " = :unlockTime WHERE " + name() + " = :name"; }
Isn't it more safe to add "+ lockedBy() + " = :lockedBy" to the where clause?

@lukas-krecan
Copy link
Owner

Hi, originally, the purpose of lockedBy was only to ease debugging. Later I used it for lock extension and I agree that the fact that it's not used in unlocking does not feel consistent.
Let's think about the trade-offs:

  • In normal situation, when the lock is held by only one node it does not matter if we take lockedBy into account or not - the condition will be always true. The only interesting case is a wierd situation when the lock is held by multiple nodes at once. I do not think it can happen but lets assume it can.
  • If we take lockedBy into account, unlock may fail. What to do in such case? Try again? Throw an exception? Only log it and otherwise ignore it? The best way would IMO be to log it - we would see that the unexpected situation happened. This is the difference from the lock extension - the API forces you to expect that the extension may fail, there is nothing like that in unlock.

But let me think about it, not unlocking due to differing lockedBy and logging an error may be a bit better then unlocking a lock held by somebody else. The thing is that I do not like to do changes that do not have a clear benenfit because there are always some unintended consequeces.

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

2 participants