rwynn / monstache

a go daemon that syncs MongoDB to Elasticsearch in realtime. you know, for search.
https://rwynn.github.io/monstache-site/
MIT License
1.28k stars 181 forks source link

Read preference secondary not working #341

Open shijin-p opened 4 years ago

shijin-p commented 4 years ago

Monstache is reading from Primary instead of secondary. Connection, permission, etc is present to secondary nodes as well. Tried readPreference=secondaryPreferred and readPreference=secondary and found no change in the read behaviour. Getting no error in logs. Sync is working.

mongo-url=mongodb://<uname>:<pswd>@host1:27017,host2:27017,host3:27017/dbname?connect=direct&replicaSet=rs0&readPreference=secondaryPreferred

mongo-url=mongodb://<uname>:<pswd>@host1:27017,host2:27017,host3:27017/dbname?connect=direct&replicaSet=rs0&readPreference=secondary

Note:- monstache v6 with ES 7.5 and Mongo 3.6

Is there anything wrong with the mongo url?

rwynn commented 4 years ago

Can you try to remove connect=direct from the URL? My understanding is that setting enables a direct connection to a single server and would disable the replica set features in the driver.