The ensureConsistentDb loop wasn't working right. Specifically, if a
document other than the last wasn't correct, it would be fixed, but that
would then change revision numbers meaning that when we checked
later docs they would then have a different _rev so attempts to change
them would fail. This is now fixed.