The lock is released right before requeuing for retry.  Before the task yields control, either through an error, a success, or a retry, the update_subtask_status() method is called, which "finally" releases the lock.