This invariant makes an assumption that index builds will not throw database exceptions except for when they commit, and we hold an X collection lock.
I thought I covered every exception-throwing region of index builds, but I think I missed a spot. We should move this DatabaseShardingState version check inside the subsequent try-catch block. We're already holding an X lock there so it will abort the index build as usual if the assertion fails.