Reputation: 91
I am creating a new collection in a new database on the sharded environment.
I am getting the following error while coll.insertMany(list)
.
Exception in thread "main" com.mongodb.MongoCommandException:
Command failed with error 133: 'unable to target write op for collection dbname.collection:: caused by ::
FailedToSatisfyReadPreference: Could not confirm non-existence of database "dbname" due to inability to query the config server primary :: caused by ::
FailedToSatisfyReadPreference: could not find host matching read preference { mode: "primary" } for set csReplSet' on server ip:27017.
The full response is { "ok" : 0, "code" : 133, "errmsg" : "unable to target write op for collection dbname.collection:: caused by ::
FailedToSatisfyReadPreference: Could not confirm non-existence of database \"dbname\" due to inability to query the config server primary :: caused by ::
FailedToSatisfyReadPreference: could not find host matching read preference { mode: \"primary\" } for set csReplSet" }
Upvotes: 3
Views: 18127
Reputation: 3646
There is possibility of read preference member is not available in replicaset in your case i.e primary not available.
For one or more reason's.
https://docs.mongodb.com/manual/tutorial/troubleshoot-sharded-clusters/
Upvotes: 0
Reputation: 5466
It looks like Read Preference is creating problem in your end.
Please go thru read preference and set which is more appropriate for your application
https://docs.mongodb.com/manual/reference/read-preference/
If your issue is something related to the one which is mentioned in below jira then we need mongo version 3.3.11 and currently we have only 3.2.9 released.
https://jira.mongodb.org/browse/SERVER-22620
Upvotes: 4