Write guarantees and retries
What each write concern means in TeselaDB and how writes are retried.
Choose when a write answers with the write concern. The driver retries on its own the ones that fail because a node went down.
Requirements
- A connection with a user that has
readWriteon the database.
Choose the write concern
| Value | Answers when |
|---|---|
w: 1 | The write is in the log of the range leader. |
w: "majority" | A majority of the range replicas have it. |
JavaScript
db.orders.insertOne({ total: 10 }, { writeConcern: { w: "majority", wtimeout: 5000 } });Retries
The drivers' retryable writes are on. If the leader of a range goes down, the driver retries the operation in flight. A retried write is not applied twice.
Check
With w: "majority", the write that answered is still there even if the leader that took it goes down.
Common problems
- A
w: 1write can be lost if the leader goes down before a majority has it. Reads do not see it until a majority has it.