[GODRIVER-1296] Connecting to an MMAPv1 deployment with driver version 1.1.0 throws errors Created: 04/Sep/19  Updated: 27/Oct/23  Resolved: 10/Sep/19

Status: Closed
Project: Go Driver
Component/s: CRUD
Affects Version/s: 1.1.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Tomer Yakir Assignee: Divjot Arora (Inactive)
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends

 Description   

Connecting to deployments running mongodb with MMAPv1 with default client options errors indicating that the deployment doesn’t support retryWrites. The workaround is to explicitly turning off retryWrites by using SetRetryWrites(false)



 Comments   
Comment by Louisa Berger [ 10/Sep/19 ]

Thank you for your investigation and clarification Divjot! We will implement a workaround in the automation agent code. Feel free to close out however you wish.

For posterity – this spec has the rationale for this at the bottom: DRIVERS-699

Comment by Divjot Arora (Inactive) [ 10/Sep/19 ]

tomer.yakir I've done some more investigation and I think the driver is behaving as expected. As far as I can tell, this does not occur on MMAPv1 clusters for versions < 3.6. For versions >= 3.6, an MMAPv1 deployment reports wire version 6 and a non-zero logicalSessionTimeoutMinutes field in its isMaster responses. Because of this, the driver concludes that the deployment supports sessions and adds a txnNumber field when doing a write operation to set up a retryable write. However, MMAPv1 does not support transactions and the server returns error code 20 (IllegalOperation), which the driver catches and wraps as per GODRIVER-1219.

This doesn't happen in the 1.0.0 driver because retryable writes were not on by default until the 1.1.0 release (GODRIVER-822).

Comment by Tomer Yakir [ 10/Sep/19 ]

divjot.arora apologies for the confusion. The problem does not occur when connecting to <3.6 deployments. It does occur when connecting to MMAPv1 deployments (regardless of the version).

Comment by Louisa Berger [ 09/Sep/19 ]

tomer.yakir Could you provide Divjot with more details for the repro?

Comment by Divjot Arora (Inactive) [ 09/Sep/19 ]

louisa.berger Can you give some more details about this issue that I could use to write a repro? I'm running the following code using the master branch of the driver against a 3.4 server:

 

package main
 
import (
   "context"
   "fmt"
   "log"
 
   "go.mongodb.org/mongo-driver/bson"
   "go.mongodb.org/mongo-driver/event"
   "go.mongodb.org/mongo-driver/mongo"
   "go.mongodb.org/mongo-driver/mongo/options"
)
 
func main() {
   ctx := context.Background()
   opts := options.Client().ApplyURI("mongodb://localhost:27017").SetMonitor(&event.CommandMonitor{
      Started: func(_ context.Context, e *event.CommandStartedEvent) {
         fmt.Printf("%v\n\n", e.Command)
      },
      Succeeded: func(context.Context, *event.CommandSucceededEvent) {},
      Failed:    func(context.Context, *event.CommandFailedEvent) {},
   })
   client, err := mongo.Connect(ctx, opts)
   if err != nil {
      log.Fatal(err)
   }
   defer func() { _ = client.Disconnect(ctx) }()
 
   coll := client.Database("foo").Collection("bar")
   _, err = coll.InsertOne(ctx, bson.D{{"x", 1}})
   if err != nil {
      log.Fatal(err)
   }
}

The insert sent to the server does not include a transaction number, which it would if the driver was setting up a retryable write.

 

Comment by Louisa Berger [ 06/Sep/19 ]

Thanks Divjot! 

Comment by Divjot Arora (Inactive) [ 06/Sep/19 ]

louisa.berger Thanks for letting me know. I'm trying to figure out the issue today and am planning to put this into progress on Monday.

Comment by Louisa Berger [ 06/Sep/19 ]

Hi divjot.arora

Wanted to call out that this bug is blocking us from upgrading the MongoDB Agent in Cloud to the 1.1.x driver, which we're eager to do so that we can start supporting the all paths index in Data Explorer. Is it possible to prioritize this fix so that we can upgrade soon? 

Thank you! 

Generated at Thu Feb 08 08:36:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.