13. Consider the following write operation issued against a 3-node replica set: db.products.update( { "name": "laptop", "price_USD": NumberDecimal(800) }, { "$inc": { "quantity": 1 } }, { "w": 3 } ) This write operation is very slow and blocks other operations on the client. Which of the following operations will mitigate any potential blocking of other operations in the client? Check all that apply:
题目选项
- A.db.products.update( { "name": "laptop", "price_USD": NumberDecimal(800) }, { "$inc": { "quantity": 1 } }, { "w": 2 } )
- B.db.products.update( { "name": "laptop", "price_USD": NumberDecimal(800) }, { "$inc": { "quantity": 1 } }, { "w": 3, "wtimeout": 4500 } )
- C.db.products.update( { "name": "laptop", "price_USD": NumberDecimal(800) }, { "$inc": { "quantity": 1 } }, { "w": 4 } )
答案置信度:中
正确答案:A、B
解析语言:中文
阻塞的根源是这条写要等到 w:3(三个节点全部确认)才返回。把 w 降为 2 只需多数确认即可返回,等待时间明显缩短,A 有效;保持 w:3 但补上 wtimeout 则保证超时后不再阻塞、把错误交还给客户端,B 也有效。C 把 w 提高到 4 只会更难满足(三节点副本集上 w:4 基本无法达成),反而加剧阻塞,是最该排除的选项。