So doing this without a code sample might make this harder but let me try to explain the problem we are having.
We have a page configuration doc in MongoDB, with 7-10 nodes deep of hierarchy.
A few levels down we have an object let's call this Sections, then each section has nodes called Widgets. So the Doc has Sections, and Sections have Widgets. Docs, Sections and Widgets all have config data/properties but let's ignore that for now.
In our API we have one call to add new sections POST /sections/new, and other one to add widgets to sections POST /sections//widgets/new.
The front end uses promises to wait for the section to be completed before asking for the widget to be created, and the backend waits for the mongo driver to return a success on the write before responding to the front end. So if everything were to work as expected, the front end's request to add a widget would succeed.
- http request to add section
- server update query to mongo to update subdoc, and add new section
- server response to front end.
- http request to add widget
- server update query to mongo to update subdoc, and add new widget to new section
- server response to front end.
- happy user.
In our scenario #5 seems to be failing, because it can't find the subdoc/ the new section.
We have tried playing with WriteConcern=1, Fsync, safe=true, journaling=true, but none of it seems to work.
What are we missing? What are we not doing to make this work? Is this even viable?
PS. I'm told that the information in questions like this one are out of date. Read-your-own-writes consistency in Mongodb