lukas-krecan / ShedLock

Distributed lock for your scheduled tasks
Apache License 2.0
3.58k stars 508 forks source link

JDBC provider - unlock logic ignores the lockedBy property #1986

Open rshisman opened 2 months ago

rshisman commented 2 months ago

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 commented 2 months ago

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:

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.