writeToJournal

Specifies whether the write operation must acknowledge being written to the journal.

Once an operation has been written to the journal, it is much less likely that it will be rolled back, even if in case of failure. However, roll back may still happen. To learn more, see the journal documentation.

If set to true, the nodes specified by acknowledgment must additionally write the operation to their journal, which forces the journal to be written to disk.

If this field is null (default), the MongoDB default applies, which depends on the deployment configuration. For example, on some deployments, WriteAcknowledgment.Majority implies that writeToJournal is set to true. To avoid surprises, we recommend always specifying this option.

Example

collections.updateMany(
options = {
writeConcern(WriteConcern(writeToJournal = true))
}
) {
User::age inc 1
}

External resources

See also

Specify this option.