Backport of #24898 Cherry-picked: 1b66db72 60225284 28d9ad28 But manually since we renamed stuff and the repair procedures changed