[backport] Fix unexpected exception when delete task with deleted milestone.