There is an intermittent failure in:
(seems to block pr ci, and reproduced for me 20% of the time)
if the db currentTime has not moved on, using the same lease time results in a failure. A renew immediately after acquiring the lock is a sensible pattern to verify the aquire.
The lock renew needs >= in place or > on the WHERE clause to allow an 'identity' lease to succeed.