wolfogre / blog-utterances

utterances of my blog.
5 stars 0 forks source link

在分片的 MongoDB Collection 上做更新操作时需要注意的问题 #21

Open wolfogre opened 6 years ago

wolfogre commented 6 years ago

https://blog.wolfogre.com/posts/trap-of-update-on-sharding-mongodb/

chanson-chan commented 4 years ago

upsert:true 的情况, 虽然 mongos 知道 _id 是唯一的, 但是 _id 不是分片键, mongos 不清楚 _id 落在哪个分片上, 如果在所有 shard 实例上执行这条语句, 可能会导致每个 shard 都插入数据