It turns out that calling with(consistency: :strong) at the class level will only apply it to the next request . Therefore, the class method is called when the class is loaded, establishing strong consistency for the first request, but subsequent requests do not start the same class method, leaving their continuity operations to work with a possible sequence. From Mongoid 3.1.7 documentation :
Tell us about the next [sic] operation to save to a specific collection, database, or session.
This method does not apply persistence parameters that can be passed (for example, several other methods in the class), so we can also pass consistency: :strong .
Hack fix
To apply this to every save operation *, I added it to default_scope .
class App default_scope -> { with(consistency: :strong); where({}) } end
In this case, the default region expects the Mongoid Criteria object to return, so we return the noop where clause after setting the level of consistency in the continue operation.
* This will not apply if the developer decides to call unscoped and disable default_scope .
source share