Add cache-based locking to subtasks to ensure that the same task is not running in two workers at the same time.