MongoDB Documentation, Release 3.0.4 Write Concern Reference Available Write Concern Write concern (page 78) describes the guarantee that MongoDB provides when reporting on the success of a write operation. Changed in version 2.6: A new protocol for write operations (page 852) integrates write concerns with the write oper- ations and eliminates the need to call the getLastError command. Previous versions required a getLastError command immediately after a write operation to specify the write concern. Write concern can include the w (page 130) option to specify the required number of acknowledgments before return- ing, the j (page 130) option to require writes to the journal before returning, and wtimeout (page 131) option to specify a time limit to prevent write operations from blocking indefinitely. In sharded clusters, mongos instances will pass the write concern on to the shard. w Option The w option provides the ability to disable write concern entirely as well as specify the write concern for replica sets . MongoDB uses w: 1 as the default write concern. w: 1 provides basic receipt acknowledgment. The w option accepts the following values: j Option The j option confirms that the mongod instance has written the data to the on-disk journal. This ensures that data is not lost if the mongod instance shuts down unexpectedly. Set to true to enable. 130 Chapter 3. MongoDB CRUD Operations Value Description 1 Provides acknowledgment of write operations on a standalone mongod or the primary in a replica set. This is the default write concern for MongoDB. 0 Disables basic acknowledgment of write operations, but returns information about socket exceptions and networking errors to the application. If you disable basic write operation acknowledgment but require journal commit acknowledgment, the journal commit prevails, and the server will require that mongod acknowledge the write operation. <Number greater than 1> Guarantees that write operations have propagated successfully to the specified number of replica set members including the primary. For example, w: 2 indicates acknowledgements from the primary and at least one secondary. If you set w to a number that is greater than the number of set members that hold data, MongoDB waits for the non-existent members to become available, which means MongoDB blocks indefinitely. "majority" Confirms that write operations have propagated to the majority of voting nodes: a majority of the replica set’s voting members must acknowledge the write operation before it succeeds. This allows you to avoid hard coding assumptions about the size of your replica set into your application. Changed in version 3.0: In previous versions, w: "majority" refers to the majority of the replica set’s members. Changed in version 2.6: In Master/Slave (page 596) deployments, MongoDB treats w: "majority" as equivalent to w: 1 . In earlier versions of MongoDB, w: "majority" produces an error in master/slave (page 596) deployments. <tag set> By specifying a tag set (page 635), you can have fine-grained control over which replica set members must acknowledge a write operation to satisfy the required level of write concern.