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

Cannot create namespace in multi-document transaction

    • Type: Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: CRUD
    • Labels:
      None
    • Environment:
      MacOs, latest mongo-community

      I am using GoDriver mongo in GraphQL, trying to do transaction for `insertOne` but always got error like this

      (NamespaceNotFound) Cannot create namespace production.people in multi-document transaction.

      I do create mongo replica as well,
      const MONGODB_URI = "mongodb://localhost:27017,localhost:27018,localhost:27019/?replicaSet=rs"
      ctx := context.Background()
      client, err := mongo.Connect(ctx, options.Client().ApplyURI(MONGODB_URI))
      if err != nil {
      panic(err)
      }

      db := client.Database("production")
      defer db.Client().Disconnect(ctx)
      col := db.Collection("people")

      // transaction
      err = db.Client().UseSession(ctx, func(sessionContext mongo.SessionContext) error {
      err := sessionContext.StartTransaction()
      if err != nil

      { fmt.Println(err) return err }

      _, err = col.InsertOne(sessionContext, req)
      if err != nil {
      sessionContext.AbortTransaction(sessionContext)
      fmt.Println(err)
      return err
      } else {
      sessionContext.CommitTransaction(sessionContext)
      }
      return nil
      })

      if err != nil {
      return nil, err

       

      I have follow the instructions of this question in Stackoverflow and I have tried also ways from this article mongodb developer

      but not lucky and always got issue like above, I have follow on your test also , still the same, any idea? or my code has something wrong?? if no, is this a bug?

      Thank you

      {{}}

            Assignee:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Reporter:
            myhoomac@hotmail.com Muhammad Only
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: