Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a node.js app with mongodb backend going to production in a week and i have few doubts on how to handle app crashes and restart .

Say i have a simple route /followUser in which i have 2 database operations

/followUser
----->Update User1 Document.followers = User2
----->Update User2 Document.followers = User1
----->Some other mongodb(via mongoose)operation

What happens if there is a server crash(due to power failure or maybe the remote mongodb server is down ) like this scenario :

----->Update User1 Document.followers = User2
 SERVER CRASHED , FOREVER RESTARTS NODE

What happens to these operations below ? The system is now in inconsistent state and i may have error everytime i ask for User2 followers

----->Update User2 Document.followers = User1
----->Some other mongodb(via mongoose)operation

Also please recommend good logging and restart/monitor modules for apps running in linux

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.