简体   繁体   中英

MongoDB transactions clarification

So starting from 4.0 version MongoDB supports multi-document transaction and one thing I can not find answer to is the following. If i have a replica set consisting of a PRIMARY and SECONDARY instance on the SAME server, what would happen if an unexpected shutdown on the server or on the MongoDB instances occurs, while a transaction is running (for example the server shuts down in the middle of the transaction)? What would happen with the data after the shutdown and after I start the MongoDB instances again? I have tried replicating this where in the middle of a transaction my code executes a terminal script to stop both mongodb services, but I have the feeling there is a better way to replicate this scenario. The results I got from this test were inconclusive. Thanks in advance !!!

If the server process dies while there are in progress transactions, when the process starts again it should go through these transactions and abort them. Any data written as part of those transactions will be discarded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM