Fixes #8316: Removing a host can create a huge transaction
(cherry picked from commit 3e7507198f25b41b90a55115671fe0edd495f531)
Fixes #8316: Removing a host can create a huge transaction
(cherry picked from commit 3e7507198f25b41b90a55115671fe0edd495f531)