Avoid UNABLE_TO_LOCK_ROW

UNABLE_TO_LOCK_ROW happens when master event is deleted before deleting the slave events.