0

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.

  1. http request to add section
  2. server update query to mongo to update subdoc, and add new section
  3. server response to front end.
  4. http request to add widget
  5. server update query to mongo to update subdoc, and add new widget to new section
  6. server response to front end.
  7. 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

Community
  • 1
  • 1
jdavid.net
  • 741
  • 9
  • 16
  • You are right, code examples are needed. Are you reading from secondaries at any point? If not, then RYOW should not be an issue, as long as you wait for a response confirming that your write has been committed. – daveh Apr 16 '14 at 07:33
  • @daveh, we are using WriteConcern which forces a wait, but even then 2.6 was having issues when updating an objects document. – jdavid.net Apr 16 '14 at 22:38
  • How are you querying for the objects in question? Are you using a query then save? Or are you issuing an update? Are you using any read preference (this is distinct from write concern)? I'd need a lot more context about what you are doing to make any determinations about what the issue is – daveh Apr 16 '14 at 23:37

0 Answers0