writeTimeout
Specifies a time limit for a write operation to propagate to enough members to achieve acknowledgment and writeToJournal.
If acknowledgment is set to 0 or 1 nodes, this setting does nothing.
If the write operation cannot be acknowledged in less than this timeout, MongoDB returns a write concern exception, even if the operation may have later succeeded. In that case, the operations are not undone.
You may also be interested in the maxTime
option.
If this option is set to null
and the acknowledgment and writeToJournal options are unachievable, the write operation will block indefinitely.
writeTimeout of 0 is equivalent to null
.
Example
collections.updateMany(
options = {
writeConcern(WriteConcern(writeTimeout = 2.minutes))
}
) {
User::age inc 1
}
Content copied to clipboard
External resources
See also
Specify this option.