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

unable to decode message length

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.1.3
    • Component/s: Connections
    • None
    • Environment:
      mongo server 3.2
      Linux Enterprise Server 7.0 x86_64

      I have a secondary mongo server 3.2, and my client code below prints error.

      func main() {func main() { var connString string if len(os.Args) < 2 { fmt.Fprintf(os.Stderr, "mongo <server connection string>") connString = "mongodb://127.0.0.1:27017/?connect=direct" } else { connString = os.Args[1] } clientOptions := options.Client().ApplyURI(connString) clientOptions.SetConnectTimeout(time.Duration(2000) * time.Millisecond) clientOptions.SetSocketTimeout(time.Duration(5000) * time.Millisecond) clientOptions.SetServerSelectionTimeout(time.Duration(2000) * time.Millisecond) ctx, _ := context.WithTimeout(context.Background(), time.Duration(5000)*time.Millisecond) client, err := mongo.Connect(ctx, clientOptions) if err != nil { fmt.Fprintf(os.Stderr, "connect mongo failed: %s\n", err.Error()) os.Exit(1) } defer client.Disconnect(ctx)
       err = client.Ping(context.TODO(), readpref.Primary()) if err != nil { fmt.Fprintf(os.Stderr, "ping mongo failed: %s\n", err.Error()) os.Exit(1) }
       coll := client.Database("maicai").Collection("station_order")
       var now = time.Now() timestamp0 := now.Truncate(30 * time.Minute) var unixTime int64 unixTime = timestamp0.Unix()
       projections := bson.D{ {"_id", 0}, {"order_number", 1}, {"station_id", 1}, {"status", 1}, {"finish_time", 1}, {"goods.origin_price", 1}, {"goods.price", 1}, {"goods.id", 1}, {"goods.count", 1}, {"goods.purchase_stockout", 1}, }
       findOptions := options.Find() findOptions.SetProjection(projections)
       cur, err := coll.Find( ctx, bson.D{ {"finish_time", bson.D{ {"$gte", unixTime}, }}, {"status", bson.D{ {"$in", bson.A{2}}, }}, }, findOptions, )
       if err != nil { fmt.Fprintf(os.Stderr, "mongo find failed: %s\n", err.Error()) os.Exit(1) } orders := make([]StationOrder, 0, 20000) err = cur.All(context.Background(), &orders) if err != nil { fmt.Fprintf(os.Stderr, "Query mongo station order failed: %s", err.Error()) os.Exit(1) }
       t := time.Unix(unixTime, 0) fmt.Fprintf(os.Stdout, "Orders from mongo DB: time = %s, count = %d", t.Format("2006-01-02 15:04:05"), len(orders))}
      

      > ./mongo "mongodb://10.8.72.37:39117/maicai?connect=direct&readPreference=secondary"
      mongo find failed: connection(10.8.72.37:39117[-3]) unable to decode message length: read tcp 10.23.30.32:41672->10.8.72.37:39117: i/o timeout

      >

       

      while the native mongo command works after setting slaveOK

       

      > mongo hidden.mgdorder.srv.mc.dd:39117
      MongoDB shell version: 2.6.12
      connecting to: hidden.mgdorder.srv.mc.dd:39117/test
      Server has startup warnings:
      2019-11-26T11:17:11.537+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
      2019-11-26T11:17:11.537+0800 I CONTROL [initandlisten]
      2019-11-26T11:17:11.538+0800 I CONTROL [initandlisten]
      2019-11-26T11:17:11.538+0800 I CONTROL [initandlisten] ** WARNING: You are running on a NUMA machine.
      2019-11-26T11:17:11.538+0800 I CONTROL [initandlisten] ** We suggest launching mongod like this to avoid performance problems:
      2019-11-26T11:17:11.538+0800 I CONTROL [initandlisten] ** numactl --interleave=all mongod [other options]
      2019-11-26T11:17:11.538+0800 I CONTROL [initandlisten]
      2019-11-26T11:17:11.538+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
      2019-11-26T11:17:11.538+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
      2019-11-26T11:17:11.538+0800 I CONTROL [initandlisten]
      2019-11-26T11:17:11.538+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
      2019-11-26T11:17:11.538+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
      2019-11-26T11:17:11.538+0800 I CONTROL [initandlisten]
      ddmc_order:SECONDARY> use maicai
      switched to db maicai
      ddmc_order:SECONDARY> db.setSlaveOk()
      ddmc_order:SECONDARY>

            Assignee:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Reporter:
            mikehb78@icloud.com 滨 黄
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: