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

Make CSOT feature-gated behavior the default

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.0.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Major Change
    • Needed
    • Hide

      1. What would you like to communicate to the user about this feature?

      V2 has removed operation-specific timeout options. Instead, users should time out operations using either the client-level operation timeout defined by ClientOptions.Timeout or by setting a deadline on the context object passed to an operation. The following fields and methods have been removed:

      • AggregateOptions.MaxTime and AggregateOptions.SetMaxTime
      • ClientOptions.SocketTimeout and ClientOptions.SetSocketTimeout
      • CountOptions.MaxTime and CountOptions.SetMaxTime
      • DistinctOptions.MaxTime and DistinctOptions.SetMaxTime
      • EstimatedDocumentCountOptions.MaxTime and EstimatedDocumentCountOptions.SetMaxTime
      • FindOptions.MaxTime and FindOptions.SetMaxTime
      • FindOneOptions.MaxTime and FindOneOptions.SetMaxTime
      • FindOneAndReplaceOptions.MaxTime and FindOneAndReplaceOptions.SetMaxTime
      • FindOneAndUpdateOptions.MaxTime and FindOneAndUpdateOptions.SetMaxTime
      • GridFSFindOptions.MaxTime and GridFSFindOptions.SetMaxTime
      • CreateIndexesOptions.MaxTime and CreateIndexesOptions.SetMaxTime
      • DropIndexesOptions.MaxTime and DropIndexesOptions.SetMaxTime
      • ListIndexesOptions.MaxTime and ListIndexesOptions.SetMaxTime
      • SessionOptions.DefaultMaxCommitTime and SessionOptions.SetDefaultMaxCommitTime
      • TransactionOptions.MaxCommitTime and TransactionOptions.SetMaxCommitTime

      This example illustrates how to define an operation-level timeout using V2, without loss of generality.

      // V1 
      
      findOneOpts := options.FindOne().SetMaxTime(1 * time.Second)
      
      res := coll.FindOne(context.TODO(), bson.D{{"age", 25}}, findOneOpts)
      if err := res.Err(); err != nil {
            log.Fatalf("failed to run find command: %v", err)
      }
      
      // V2
      
      ctx, cancel := context.WithTimeout(context.TODO(), time.Second)
      defer cancel()
      
      res := coll.FindOne(ctx, bson.D{{"age", 25}})
      if err := res.Err(); err != nil {
      	log.Fatalf("failed to run find command: %v", err)
      }
      

      Similarly, WTimeout field has been removed from the WriteConcern struct. Instead, users should define a timeout at the operation-level using a context object.

      2. Would you like the user to see examples of the syntax and/or executable code and its output?

      New examples are not required, but existing examples that apply setting a timeout using options need to be updated to set a timeout using a context.

      3. Which versions of the driver/connector does this apply to?
      v2

      Show
      1. What would you like to communicate to the user about this feature? V2 has removed operation-specific timeout options. Instead, users should time out operations using either the client-level operation timeout defined by ClientOptions.Timeout or by setting a deadline on the context object passed to an operation. The following fields and methods have been removed: AggregateOptions.MaxTime and AggregateOptions.SetMaxTime ClientOptions.SocketTimeout and ClientOptions.SetSocketTimeout CountOptions.MaxTime and CountOptions.SetMaxTime DistinctOptions.MaxTime and DistinctOptions.SetMaxTime EstimatedDocumentCountOptions.MaxTime and EstimatedDocumentCountOptions.SetMaxTime FindOptions.MaxTime and FindOptions.SetMaxTime FindOneOptions.MaxTime and FindOneOptions.SetMaxTime FindOneAndReplaceOptions.MaxTime and FindOneAndReplaceOptions.SetMaxTime FindOneAndUpdateOptions.MaxTime and FindOneAndUpdateOptions.SetMaxTime GridFSFindOptions.MaxTime and GridFSFindOptions.SetMaxTime CreateIndexesOptions.MaxTime and CreateIndexesOptions.SetMaxTime DropIndexesOptions.MaxTime and DropIndexesOptions.SetMaxTime ListIndexesOptions.MaxTime and ListIndexesOptions.SetMaxTime SessionOptions.DefaultMaxCommitTime and SessionOptions.SetDefaultMaxCommitTime TransactionOptions.MaxCommitTime and TransactionOptions.SetMaxCommitTime This example illustrates how to define an operation-level timeout using V2, without loss of generality. // V1 findOneOpts := options.FindOne().SetMaxTime(1 * time.Second) res := coll.FindOne(context.TODO(), bson.D{{ "age" , 25}}, findOneOpts) if err := res.Err(); err != nil { log.Fatalf( "failed to run find command: %v" , err) } // V2 ctx, cancel := context.WithTimeout(context.TODO(), time.Second) defer cancel() res := coll.FindOne(ctx, bson.D{{ "age" , 25}}) if err := res.Err(); err != nil { log.Fatalf( "failed to run find command: %v" , err) } Similarly, WTimeout field has been removed from the WriteConcern struct. Instead, users should define a timeout at the operation-level using a context object. 2. Would you like the user to see examples of the syntax and/or executable code and its output? New examples are not required, but existing examples that apply setting a timeout using options need to be updated to set a timeout using a context. 3. Which versions of the driver/connector does this apply to? v2

      Certain CSOT behavior is "feature-gated" in pre-2.0 versions of the driver when Timeout is declared:

      1. Retrying all operations as many times as the context allows
      2. Automatic calculation and appension of “maxTimeMS” 
      3. Using the min RTT as a threshold for “short-circuiting” (described in the “Command Execution” section)

      In 2.0, fully remove all deprecated options and methods, and make the above behaviors the default (not gated by the presence of Timeout).

      Definition of done:

      • Update connectTimeoutMS to cover all blocking operations during connection establishment, including MongoDB handshake and auth.
      • Remove all deprecated timeout options.
      • All behavior conditionally enabled by the presence of a timeoutMS configuration should be the new default behavior.

            Assignee:
            preston.vasquez@mongodb.com Preston Vasquez
            Reporter:
            benji.rewis@mongodb.com Benji Rewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: