MongoDB DBA · Question 294 · Multiple choice

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:

Answer options

  1. A.
    db.products.update( { "name": "laptop", "price_USD": NumberDecimal(800) }, { "$inc": { "quantity": 1 } }, { "w": 2 } )
  2. B.
    db.products.update( { "name": "laptop", "price_USD": NumberDecimal(800) }, { "$inc": { "quantity": 1 } }, { "w": 3, "wtimeout": 4500 } )
  3. C.
    db.products.update( { "name": "laptop", "price_USD": NumberDecimal(800) }, { "$inc": { "quantity": 1 } }, { "w": 4 } )

Answer confidence: Medium

Correct answer: A, B

Explanation language: Chinese

阻塞的根源是这条写要等到 w:3(三个节点全部确认)才返回。把 w 降为 2 只需多数确认即可返回,等待时间明显缩短,A 有效;保持 w:3 但补上 wtimeout 则保证超时后不再阻塞、把错误交还给客户端,B 也有效。C 把 w 提高到 4 只会更难满足(三节点副本集上 w:4 基本无法达成),反而加剧阻塞,是最该排除的选项。

Papers containing this question

This question appears in 3 bank records. Public pages combine identical prompts and options. Selected questions display the highest-confidence record; the others show a short preview. Paper-based learning preserves each record's answer, explanation, and confidence.

AUTHOR · PROJECTS · OPEN SOURCE

Author & MongoDB projects

Building data platforms, MongoDB migration and sync tools, and cloud operations products.

Contact the author for any MongoDB needs.

Contact the author ↗mlhp123@outlook.com

Support the author

If this question bank helps you, optional donations are welcome.

Scan with Alipay to support the authorOpen full-size donation image ↗