This is a creation in Article, where the information may have evolved or changed.
MgO Write security mechanism
- MONGO Write security
- MgO Write safe
MONGO Write security
MONGO itself has a full set of write security mechanisms, but only a small subset of the relevant parts are covered in this article. Put a link to skip this section without looking directly at this
Link.
- Writeconcern.none: No exception thrown
- Writeconcern.normal: Throw only network error exception, no server error exception
- Writeconcern.safe: Throws a network error exception, server error exception, and waits for the server to complete the write operation.
- Writeconcern.majority: Throws a network error exception, server error exception, and waits for a master server to complete the write operation.
- Writeconcern.fsync_safe: Throws network error exception, server error exception, write operation waits for server to flush data to disk.
- Writeconcern.journal_safe: Throws a network error exception, a server error exception, and a write operation waits for the server to submit a log file to disk.
- Writeconcern.replicas_safe: Throws a network error exception, server error exception, wait for at least 2 servers to complete the write operation.
MgO Write safe
First put the safe structure in MgO.
type Safe struct { W int // Min # of servers to ack before success WMode string // Write mode for MongoDB 2.0+ (e.g. "majority") WTimeout int // Milliseconds to wait for W before timing out FSync bool // Sync via the journal if present, or via data files sync otherwise J bool // Sync via the journal if present}
- The W parameter corresponds to the Replicas_safe, which is waiting for the W server to complete the write operation
- WMode can write MONGO security in the top four. " None "," normal "," safe "," majority "
- Wtimeout notes are pretty clear written.
- FSync writes asynchronous write to synchronous write, which is to wait for MONGO to return write feedback
- J is equivalent to waiting for the log to be written back.