Use primary read preference for validates_uniqueness_of

XMLWordPrintableJSON

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

      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 (Inactive)
              Reporter:
              Johnny Shields
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: