|
|
|
|
|
by nurettin
3425 days ago
|
|
Well, thanks for the question! You check the result with getLastError which, as you described, can be used to ensure a majority agrees with the write. But you normally don't use getLastError that way. Because a majority might not even be concerned with that particular write. They are, after all, shards. Instead you check if primary got the write. If primary disconnects while you are checking, you catch the exception and try checking until a new primary is decided. And if your check result is not ok, you try inserting again. That's as reliable as it gets when inserting to any database including SQL databases that support transactions. |
|
>that's as reliable as it gets when inserting into any database including SQL
The difference being in a SQL database you call commit and all this happens for you automatically