Got a app situation where I’m executing a bulk-write operation on a sub-collection insert. Between the line of code that writes the data, there’s about another several dozen lines of code that executes, including writing one or more log messages… then I do a fetch of the data but I’m consistently fetching the pre-write version of the record instead of the just-updated version.
There’s a slim chance the data will be on-disk and fetched proper, but it’s more likely than not to be absent, according to test results. (About 1 in 10.)
fsync() isn’t an option b/c of the overhead. This is an enterprise app so I’m not going to introduce delays, like sleep(), to make-up for a lack of write-behind caching, or collection-level write-locks because the app is asynchronous.
I was curious as to what others have done to compensate. As of now, my only option is to return the results of the operation (success, -n- records updated) forcing the user to make a subsequent call to fetch the updated record which I think is an inefficient kludge.