Mongo 3.6 replication and write concern timed out

best practicesreplication

Not sure how to ask this.
I have a process that is importing thousands of records to the database using a bulkwrite.
I process 1000 documents and then write that and then get the next thousand and write that etc.
This works perfectly in a 1 database scenario and i'm working on setting up replication.
When replicating, I'm getting a write concern error 64 "waiting for replication timed out" frequently.
I do have journaling turned on and have the rs.config set with w:majority.
My understanding is that means to be sure its written to at least the journal before the response is returned.
I'm not sure how best to handle the write concern error though.
Do i just capture it and continue on? or do I need to reprocess some records?
Both primary and secondary have the same document count when executing the count() request on the collection.
Any guidance on what best practices are for this would be helpful.
thanks.

Best Answer

"waiting for replication timed out" is not a Error , this is a warning msg that your document has not been written to majority of your replica server. but this going to be replicate.

what you can do is along with W:majority configure one more parameter wtimeout:5000 , with this you can overcome of this warning messages.

""Do i just capture it and continue on? or do I need to reprocess some records?"" You can set w:1 for specific process for example a bulk write.