Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2035

Causal Consistency by default

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.5.1, 1.5.2, 1.5.3
    • Component/s: Connections
    • Environment:
      go1.16.4
      windows
      linux
    • Fully Compatible
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      From my understanding of reading the Go driver code documentation and mongo docs client drivers should, by default, be set to use causal consistency:

      I've noticed in the Go(lang) driver, when creating a new client or creating a new session, both read concern and write concern are set to empty, but CausalConsistency/Consistent is set to true by default.

      According to the go driver docs:

      New Client:

      New Session:

      The `session.ClientSession.Consistent` property by default is set to true.

      So should the driver by default, be setting the "best practice" causal consistency preferences?

      OR when calling `client.StartSession(options.Session().SetCausalConsistency(true))` should this be setting default majority read and write concerns?

      Current implementation of `mongo/options/sessionoptions.go#ln51`

      // SetCausalConsistency sets the value for the CausalConsistency field.
      func (s *SessionOptions) SetCausalConsistency(b bool) *SessionOptions {
         s.CausalConsistency = &b
         return s
      }
      

       

       

      Suggested Implementation?

      // SetCausalConsistency sets the value for the CausalConsistency field.
      func (s *SessionOptions) SetCausalConsistency(b bool) *SessionOptions {
         s.CausalConsistency = &b
         s.DefaultReadConcern = readconcern.Majority()
         s.DefaultWriteConcern = writeconcern.New(writeconcern.WMajority())
         return s
      }
      

       

        1. new-session-client-session-defaults.png
          new-session-client-session-defaults.png
          64 kB
        2. new-session-client-default-settings.png
          new-session-client-default-settings.png
          53 kB
        3. new-client-default-settings.png
          new-client-default-settings.png
          47 kB
        4. image-2021-06-04-11-09-14-247.png
          image-2021-06-04-11-09-14-247.png
          48 kB
        5. image-2021-06-02-17-24-25-948.png
          image-2021-06-02-17-24-25-948.png
          23 kB
        6. default-best-practice-causal-consistency-params.png
          default-best-practice-causal-consistency-params.png
          38 kB

            Assignee:
            Unassigned Unassigned
            Reporter:
            matt@linc-ed.com Matt Hartstonge
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: