Open arekborucki opened 5 months ago
interesting finding. I was just debugging a similar issue about missing some documents, since I've had used readPreference=nearest
so far ..
switched to primary
now, since your explanation totally makes sense, especially since I have set the writeConcern to primary only.
"defaultWriteConcern" : {
"w" : 1,
"wtimeout" : 0
},
Thanks for pointing that out, probably saved me a few hours of debugging :-)
We have observed a problem when our Monstache instance uses MongoDB read preference "
secondary
". When we try to insert a large number of documents into MongoDB in a short time, such as 5,000 documents, not all of them are replicated to Elasticsearch. Approximately 4,950 to 4,970 are replicated. However, when we switch Monstache back to read preference "primary
", everything is replicated correctly. All documents are also correctly replicated if we use the connection string to MongoDB with only the secondary MongoDB node name and the parameterdirectConnection=true
. However, in this case, Monstache cannot insert metadata to the MongoDB database.Monstache uses a MongoDB view as the replication source in MongoDB. Here is our configuration:
Could the problem be that Monstache sees the document ID in the oplog, takes that document ID, and sends a query to one of the secondaries, e.g.,
db.contact-view.find({"id":"xyz"})
. However, the document is not yet replicated despite being in the oplog, so it gets zero documents as a result of the query ?we use MongoDB
v6.0
, Monstachev6.7.10