3 ms·
Yes, if you combine journaling with safe write operations. This allows you to call the appropriate driver method to confirm that the data has been written. You
by dmytton 16y ago
Yes, if you combine journaling with safe write operations. This allows you to call the appropriate driver method to confirm that the data has been written. You can also wait for it to be written to n slaves in replication. I believe that "written" means either to the data files or the journal. In the case of the journal, a hard crash would result in the journal being replayed so that the data is then written to disk and you don't get corruption.
For example in the PHP driver, calling insert with the safe option. http://www.php.net/manual/en/mongocollection.insert.php http://www.php.net/manual/en/mongocollection.insert.php
"If safe is an integer, will replicate the insert to that many machines before returning success (or throw an exception if the replication times out, see wtimeout)."
You can then immediately called http://www.php.net/manual/en/mongodb.lasterror.php http://www.php.net/manual/en/mongodb.lasterror.php to confirm the last operation didn't error.