sarjarapu/migrate-mongo-cluster

When source is sharded cluster - read the last entry in the oplog fails as it is using mongos instead of reconnecting to each shard

alon-brillix opened this issue · 0 comments

I have tracked the code according to the sack trace in the error (hereunder) and it looks like the mongo driver has identified it is connected to a sharded cluster but this tools does not take it into account and tries to read the oplog from the connected server, which in a sharded cluster scenario is mongos - so it fails.

[ERROR] 2022-02-23 16:23:19 ERROR [main] MongoDBHelper:72 - [UNHANDLED] error while performing operation: {"operation": "find", "query": {}}; error: com.mongodb.MongoQueryException: Query failed with error code 20 and error message '' on server mymongos:27017 Exception in thread "main" com.mongodb.MongoQueryException: Query failed with error code 20 and error message '' on server mymongos:27017 at com.mongodb.operation.FindOperation$1.call(FindOperation.java:735) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:725) at com.mongodb.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:463) at com.mongodb.operation.FindOperation.execute(FindOperation.java:725) at com.mongodb.operation.FindOperation.execute(FindOperation.java:89) at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:189) at com.mongodb.client.internal.FindIterableImpl.first(FindIterableImpl.java:205) at com.mongodb.migratecluster.trackers.ReadOnlyDataTracker.lambda$getLatestDocument$0(ReadOnlyDataTracker.java:40) at com.mongodb.migratecluster.helpers.MongoDBHelper.performOperationWithRetry(MongoDBHelper.java:46) at com.mongodb.migratecluster.trackers.ReadOnlyDataTracker.getLatestDocument(ReadOnlyDataTracker.java:38) at com.mongodb.migratecluster.migrators.OplogMigrator.getLatestOplogEntryFromSource(OplogMigrator.java:118) at com.mongodb.migratecluster.migrators.OplogMigrator.fetchRecentEntryFromSourceAndSaveToOplogstore(OplogMigrator.java:90) at com.mongodb.migratecluster.migrators.OplogMigrator.saveSourceOplogTimeOnOplogstoreIfNotExists(OplogMigrator.java:81) at com.mongodb.migratecluster.migrators.OplogMigrator.preprocess(OplogMigrator.java:50) at com.mongodb.migratecluster.migrators.DataWithOplogMigrator.preprocess(DataWithOplogMigrator.java:31) at com.mongodb.migratecluster.Application.run(Application.java:43) at com.mongodb.migratecluster.Application.main(Application.java:30)