I have 2 services. Both are connected to the same mongodb.
Both use ReplaceOne
method, and from time of time I get errors about duplicate key.
I think if ReplaceOne
removes record and insert new - it explain my problem...
So... does method ReplaceOne
remove record and insert new or update old record?
It seems to me that perhaps your services are removing and inserting the new document at the same time when they are accessed simultaneously and generating with the same id.
I hope I have helped.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.