When the rake task creates search indexes, the code that queues them up runs inside Mongoid's "collection management" scope, but the part that then waits for them to finish doesn't. It polls the database directly, unlike the other search-index paths that keep the scope.
Because of that, the persistence guard's usual pass for collection management doesn't apply, and the wait can blow up with a NoEncryptionSchema error for an encrypted model, even though the index creation right before it was fine.