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

why insert duplicate document close the client?

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • 1.0.1
    • CRUD
    • None

    Description

      After I create an unique index for a field of a document, I insert a duplicate document into mongodb, when using mgo it reports duperr, but user this driver, it reports "client is disconnected" and it disconnects from server either.

       

      IMO, this error should not close the connection to the mongodb server, but just report/return an proper error.

       

       

      mongo.InitMongo()
      client := mongo.GetClient()
      c := client.Database("api-server").Collection("users")
      var user = bson.M{"name":"bob","age":12} //duplicate document
      r, err := c.InsertOne(nil, user)
      if err != nil {
         println(err.Error())  //reports client is disconnected
      }
      // test if really disconnected
      var result bson.M
       err=c.FindOne(nil, bson.M{"name":"bob"}).Decode(&result)
      if err != nil {
         glog.Errorln(err) // really disconnected
         return
      }
       
       println(result["age"])
      
      

       

      Attachments

        Activity

          People

            divjot.arora@mongodb.com Divjot Arora (Inactive)
            yyq daniel yang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: