renameBetweenDBs has WriteConflictException handling that repositions (using seekExact) the cursor on the source collection if the RecordID of the beginning of the batch does not match the last observed RecordId. This is correct in most cases, but not if the writeConflict is observed on the first document of the batch.
In this case the cursor on the source collection will invalidated, but not repositioned. Subsequent calls to next() will start over from the beginning. This can result in erroneously copying the same data from a source collection into the destination.