Use with_advisory_lock on before_destoy callback, this should avoid deadlocks.