Class RowLock
Every claim in the engine is a guarded update whose row count picks one winner, and that is correct on its own -- but a loser gets there by waiting. It blocks on the winner's row lock until the winner commits, then updates nothing and moves on. With one node polling that costs nothing; with several, every node walks the same batch of due rows and pays that wait on every row it is not going to get.
So the loser asks first, and is told. SKIP LOCKED is what a database has for exactly
this: a locked row is not waited for, it is simply not returned.
It is asked through JPA's own lock-timeout hint rather than as SQL of our own, which matters
for one practical reason: a database without SKIP LOCKED degrades to ordinary locking
instead of failing. The protocol does not depend on the skip -- the guarded update is still what
decides the winner -- so degrading costs the waiting this was meant to avoid and nothing else.
-
Method Summary
-
Method Details
-
tryTake
Holdidfor the rest of this transaction, or answer false because somebody else is holding it. Never waits.False is not a failure and says nothing about the row beyond "not now": the row may be claimed, or merely being read by another node that is about to lose its own guarded update. The caller's answer to it is to leave this row alone and carry on with the next.
-