Write operations that use this write concern will wait for acknowledgement from the primary server before returning.
Write operations that use this write concern will wait for acknowledgement from the primary server before returning. Exceptions are raised for network issues, and server errors.
Exceptions are raised for network issues, and server errors; the write operation waits for the server to flush the data to disk.
Exceptions are raised for network issues, and server errors; the write operation waits for the server to group commit to the journal file on disk.
Exceptions are raised for network issues, and server errors; waits on a majority of servers for the write operation.
A write concern that blocks acknowledgement of a write operation until a majority of replica set members have applied it.
Exceptions are raised for network issues, and server errors; waits for at least 2 servers for the write operation.
Write operations that use this write concern will return as soon as the message is written to the socket.
Write operations that use this write concern will return as soon as the message is written to the socket. Exceptions are raised for network issues, but not server errors.
Creates a WriteConcern object, based on a tag name
Creates a WriteConcern object, based on a tag name
the tag name
timeout for write operation
whether or not to fsync
whether writes should wait for a journaling group commit
Creates a WriteConcern object.
Creates a WriteConcern object.
Specifies the number of servers to wait for on the write operation, and exception raising behavior
w
represents the number of servers:
- w=-1
None, no checking is done
- w=0
None, network socket errors raised
- w=1
Checks server for errors as well as network socket errors raised
- w>1
Checks servers (w) for errors as well as network socket errors raised
number of writes
timeout for write operation
whether or not to fsync
whether writes should wait for a journaling group commit
Creates a WriteConcern object.
Creates a WriteConcern object.
Specifies the number of servers to wait for on the write operation, and exception raising behavior
w
represents the number of servers:
- w=-1
None, no checking is done
- w=0
None, network socket errors raised
- w=1
Checks server for errors as well as network socket errors raised
- w>1
Checks servers (w) for errors as well as network socket errors raised
number of writes
timeout for write operation
whether or not to fsync
Calls WriteConcern(w: Int, wtimeout: Int, fsync: Boolean)
with w=1 and wtimeout=0
Calls WriteConcern(w: Int, wtimeout: Int, fsync: Boolean)
with w=1 and wtimeout=0
whether or not to fsync
Calls WriteConcern(w: Int, wtimeout: Int, fsync: Boolean)
with fsync=false
Calls WriteConcern(w: Int, wtimeout: Int, fsync: Boolean)
with fsync=false
number of writes
timeout for write operation
Tag based Write Concern with wtimeout=0, fsync=false, and j=false
Tag based Write Concern with wtimeout=0, fsync=false, and j=false
Write Concern tag
Calls WriteConcern(w: Int, wtimeout: Int, fsync: Boolean)
with wtimeout=0 and fsync=false
Calls WriteConcern(w: Int, wtimeout: Int, fsync: Boolean)
with wtimeout=0 and fsync=false
number of writes
Default constructor keeping all options as default.
Default constructor keeping all options as default. Be careful using this constructor, as it's equivalent to
WriteConcern.UNACKNOWLEDGED
, so writes may be lost without any errors being reported.
WriteConcern#UNACKNOWLEDGED
Create a Majority Write Concern that requires a majority of servers to acknowledge the write.
Create a Majority Write Concern that requires a majority of servers to acknowledge the write.
timeout for write operation
whether or not to fsync
whether writes should wait for a journal group commit
Majority, a subclass of WriteConcern that represents the write concern requiring most servers to acknowledge the write
Controls the acknowledgment of write operations with various options.
w
- 0: Don't wait for acknowledgement from the server - 1: Wait for acknowledgement, but don't wait for secondaries to replicate - >=2: Wait for one or more secondaries to also acknowledge
wtimeout
- how long to wait for slaves before failing- 0: indefinite - >0: time to wait in milliseconds
Other options:
-
j
: If true block until write operations have been committed to the journal. Cannot be used in combination withfsync
. Prior to MongoDB 2.6 this option was ignored if the server was running without journaling. Starting with MongoDB 2.6 write operations will fail with an exception if this option is used when the server is running without journaling. -fsync
: If true and the server is running without journaling, blocks until the server has synced all data files to disk. If the server is running with journaling, this acts the same as thej
option, blocking until write operations have been committed to the journal. Cannot be used in combination withj
. In almost all cases thej
flag should be used in preference to this one.1.0