Quoting Executing a Test:
If the test might execute a distinct command within a sharded transaction, for each target collection the test runner SHOULD execute a non-transactional distinct command on each mongos server using the internal MongoClient. See StaleDbVersion Errors on Sharded Clusters for more information.
This was already addressed via the UnifiedTestRunner::preventStaleDbVersionError() method in the original PR for
PHPLIB-493. That method is called for each test and conditionally executes a distinct command as needed.
It's unclear to me why a separate commit in the PR (added by andreas.braun after I handed things off) added what appears to be similar logic within the "distinct" operation case. See: https://github.com/mongodb/mongo-php-library/pull/783/commits/abc742618c43a5eff2961ded41d9293589f60518#diff-e1fc1998198af571cbeed186ed25b1c703850f87e91be5be15ebee8b674d29a0R311
We should investigate whether the logic within the operation case is still required. Alternatively, if it is working around a failing of the preventStaleDbVersionError method we should try to fix that directly.