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

commands meant for local node are directed to primary

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 0.0.17
    • None
    • Go 1.11
      Linux 64 bit

    Description

      We have our custom monitoring agent we run on each mongo instance, which call `serverStatus` like this:

       

       

      connectStr := fmt.Sprintf("mongodb://%s:%s@%s:%d/%s", h.Username, h.Password, "localhost", h.Port, h.Database)
      client, e := mongo.NewClient(connectStr)
      ctx, _ := context.WithTimeout(context.Background(), 3*time.Second)
      client.Connect(ctx)
      db := client.Database(h.Database)
      rdr, e := db.RunCommand(ctx, bson.NewDocument(bson.EC.Int32("serverStatus", 1))) 

       

      However, it seems the commands are always routed to the primary, since even when run on the secondaries, we get the exact same stats as the primary for metrics like connections, opcounters, opcountersRepl, etc.

      This seems to be a bug in the driver, where a query being run on 'localhost' is being directed to the primary

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            pdeva prashant deva
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: