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

Use primary read preference for validates_uniqueness_of

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 9.0.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Minor Change

      This ticket is for changing to use primary read preference for validates_uniqueness_off.

      Note that per the comments in https://github.com/mongodb/mongoid/pull/5451, the only validator that Mongoid implements that queries the database is the uniquess one. Applications with custom validatiors should adjust read preference as necessary for their validators.

      Original ticket
      --------------
      The validates uniqueness check can yield a false positive if reading from secondary and there is replication lag (i.e. the secondary does not yet have the conflicting data.) It would be useful to have a global flag to force validates_uniqueness to use read mode: primary. In my opinion this is fine as a global, I don't think we need an option on the validation itself.

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: