Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2614

Possible to make with(safe: true) the default for a model?

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.15
    • Affects Version/s: None
    • Component/s: None
    • None

      Was wondering if it would be possible have safe saves be the default for a collection/model.

      We have .create! or .save! in various places around the code for this model. We try to remain vigilant about setting them to safe, but with a large code base, they can sneak in.

      The bug manifests itself when we create a new record of this model and then some other code needs to read it right after it's saved. It seems in production under load, once in a while the read will not find the newly saved record on the first read. We have consistency: :strong set, but if I'm understanding correctly it's not guaranteed to be readable right away unless we use with(safe: true). Thanks!

            Assignee:
            Unassigned Unassigned
            Reporter:
            barmstrong Brian Armstrong
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: