yoklainterview sim

Database Mongodb Transactions Consistency Interview Questions

75 verified Database Mongodb Transactions Consistency interview questions — solve with answers, learn from explanations, test yourself in a real simulation.

Try the real simulation →

Sample questions

Mongodb Transactions ConsistencyDifficulty 1
Starting from which MongoDB version can you run multi-document ACID transactions on a replica set?
  • a3.6
  • b4.0
  • c4.2
  • d5.0
Explanation:MongoDB 4.0 introduced multi-document ACID transactions for replica sets. Sharded cluster support followed in 4.2.
Mongodb Transactions ConsistencyDifficulty 1
From which MongoDB version can multi-document transactions span a sharded cluster (across multiple shards)?
  • a3.6
  • b4.0
  • c4.2
  • d6.0
Explanation:MongoDB 4.2 extended multi-document transaction support to sharded clusters, involving multiple shards through a transaction coordinator.
Mongodb Transactions ConsistencyDifficulty 2
Which mongosh snippet correctly opens, uses, and commits a multi-document transaction?
  • as = db.getMongo().startSession(); s.startTransaction(); s.getDatabase("app").orders.insertOne({sku:1}); s.commitTransaction();
  • bdb.orders.beginTransaction(); db.orders.insertOne({...}); db.orders.endTransaction();
  • cdb.runCommand({transaction: true}); db.orders.insertOne({...});
  • ddb.orders.insertOne({...}, {transaction: "start"});
Explanation:MongoDB transactions are opened on a ClientSession with startTransaction(), operations run through that session's database handle, and commitTransaction() finalizes them. There is no per-collection beginTransaction/endTransaction API.
Mongodb Transactions ConsistencyDifficulty 2
What read concern level is used when a query specifies none and no custom default is configured?
  • amajority
  • blocal
  • csnapshot
  • dlinearizable
Explanation:With no explicit or custom default read concern, the implicit default is local: it returns the most recent data available on the node the query hits, without guaranteeing majority acknowledgment.
Mongodb Transactions ConsistencyDifficulty 2
A read with read concern majority returns a document. What does that guarantee about the document?
  • aIt was written with w: 1 and is guaranteed durable on the primary only
  • bIt is always the very latest write, even ones not yet replicated anywhere
  • cIt was read directly from a secondary, bypassing the primary entirely
  • dIt reflects data that has reached the replica set's majority-commit point
Explanation:Read concern majority returns majority-committed data, meaning it won't be rolled back by a later election. This does not mean the original write used w: "majority"; even a write acknowledged with w: 1 can later reach the majority-commit point.
Mongodb Transactions ConsistencyDifficulty 1
Before MongoDB 5.0, what was the implicit default write concern for a standalone insertOne() against a replica set when no write concern was configured?
  • aw: 1
  • bw: majority
  • cw: 0
  • dw: all
Explanation:Before MongoDB 5.0, the implicit default was w: 1: acknowledgment did not wait for replication to secondaries. Starting in MongoDB 5.0, the implicit default is w: "majority" for most replica-set topologies (with an exception for certain arbiter-containing topologies), so the version qualifier matters.

Test yourself against the 2475-question Database bank.

Start interview