October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

MongoDB Write Concern Explained: What `w:1`, `w:”majority”` and `j:true` Guarantee

MongoDB’s `w` controls the required member acknowledgments; `j:true` adds a journal requirement. Understand the rollback, timeout, topology, and version caveats.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What do w:1, w:"majority", and j:true guarantee? They set different acknowledgment conditions: w specifies how many replica-set members must acknowledge a write, while j:true requires the members counted toward that condition to record it in their on-disk journals. Neither setting is an unconditional promise that a write will survive every failure. A timeout limits how long MongoDB waits for the requested acknowledgment; it does not undo a write already applied on the primary.

What each write concern confirms

MongoDB write concern is the condition a write must meet before MongoDB reports it as acknowledged. The controls answer related but separate questions: w sets the required acknowledgment count, j specifies a journal-persistence requirement, and wtimeout limits the wait for the w condition.

As an Amazon Associate I earn from qualifying purchases.

Setting What acknowledgment confirms Important limit
w:1 In a replica set, the primary has acknowledged the write. It does not confirm replication to a secondary; the write may be rolled back if the primary steps down before another member replicates it. MongoDB Write Concern documentation and rollback documentation.
w:"majority" A calculated majority of data-bearing voting members has acknowledged the write. Arbiters do not store data and are not counted as data-bearing members for this requirement. MongoDB replica-set write concern documentation. Whether acknowledgment also waits for on-disk journal writes depends on writeConcernMajorityJournalDefault if j is not specified. MongoDB 7.0 Write Concern documentation.
j:true The members required by the selected w value have written the operation to their on-disk journals. MongoDB Write Concern documentation. It does not independently require replication to additional members or prevent rollback after failover.
wtimeout Limits how long MongoDB waits for the requested w acknowledgment condition. A write concern timeout does not undo a write that the primary already applied. MongoDB Write Concern documentation.

What does w:1 mean, and can the write be rolled back?

w:1 asks for acknowledgment from one member: in a replica set, that is the primary. It is useful when an application accepts acknowledgment from the primary without waiting for replication, but the response does not establish that a secondary has received the write.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If the primary steps down or fails before another member replicates the operation, a new primary may not contain it and MongoDB may roll it back. MongoDB’s failover guidance recommends w:"majority" with journaling enabled on voting members for the documented rollback-avoidance case. That recommendation is not a claim that every correlated or otherwise exceptional failure becomes impossible. MongoDB: Rollbacks During Replica Set Failover.

What does w:"majority" count?

w:"majority" waits for a calculated majority of data-bearing voting members, including the primary. The required count follows the replica set’s voting configuration; an arbiter can participate in elections but cannot store the write, so it is not a data-bearing acknowledgment for this requirement. MongoDB: Write Concern for Replica Sets.

Majority acknowledgment should not be described as a guarantee against every possible failure. Its persistence qualification matters: if j is omitted, the behavior depends on writeConcernMajorityJournalDefault. MongoDB 7.0 documentation says that setting defaults to true; when it is true, majority acknowledgment waits for on-disk journal writes. When false, acknowledgment need not wait for those writes, and MongoDB warns that a transient loss and restart of a majority of nodes can permit rollback. Check the setting and the server version rather than assuming majority always means journaled to disk. MongoDB 7.0 Write Concern documentation.

What j:true adds—and what it does not

j:true asks MongoDB to wait until the members required by the chosen w value have written the operation to their on-disk journals. MongoDB describes the behavior this way: “With j: true, MongoDB returns only after the requested number of members, including the primary, have written to the journal.” MongoDB Database Manual, Write Concern.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Journaling and replication are different conditions. A journaled write on the primary is not evidence that a secondary has replicated it: that requires a suitable w value. Conversely, w:"majority" with j unspecified follows the majority-journaling default described above; it is not equivalent in all configurations to explicitly requesting j:true.

What happens when a write concern times out?

If the primary applies a write but MongoDB cannot satisfy the requested acknowledgment condition before wtimeout expires, the operation can return a write concern error while the data modification remains in place on the primary. The timeout reports that the requested acknowledgment was not reached in time; it is not a cancellation or rollback mechanism. MongoDB Write Concern documentation.

Applications should therefore treat the result as acknowledgment uncertainty, not proof that the write did not happen. Blindly retrying a non-idempotent operation can cause duplicate effects; use an application-level retry strategy appropriate to the operation and verify state where needed.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Version and topology can change the practical result

Implicit defaults and arbiters

MongoDB’s implicit default write concern is generally w:"majority", but an arbiter-related topology can change it. If a replica set has arbiters and the number of data-bearing voting members does not exceed the voting majority, the implicit default is w:1. Inspect the deployment’s configured default and member roles instead of inferring them from the phrase “replica set.” MongoDB: Default Read Concerns and Write Concerns.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

MongoDB 8.0 majority acknowledgment and secondary reads

Starting in MongoDB 8.0, a majority write can be acknowledged after a majority durably writes its oplog entry, while members apply the operation asynchronously. As a result, a read from a secondary immediately after the majority acknowledgment can occur before that secondary has applied the change. Majority acknowledgment alone therefore does not guarantee immediate visibility on every secondary. MongoDB: Write Concern.

Atlas versus self-managed deployments

MongoDB documents w:"majority" as the default for Atlas clusters. That Atlas statement should not be generalized to every self-managed deployment, where the implicit default can depend on replica-set topology. MongoDB Atlas: Rollbacks During Failover.

Choosing a write concern

  • Choose w:1 when acknowledgment from the primary is sufficient for the application and it can tolerate the documented failover rollback risk.
  • Choose w:"majority" when the write should be acknowledged by a majority of data-bearing voting members; verify the journaling default and topology for the deployment.
  • Add j:true when the write must wait for journal persistence on the members counted by w; do not treat it as a substitute for replication.
  • Set wtimeout to bound acknowledgment waiting when appropriate, and handle its error as an uncertain outcome rather than assuming the operation was undone.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.