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

commands meant for local node are directed to primary

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 0.0.17
    • None
    • Environment:
      Go 1.11
      Linux 64 bit

      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

       

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

              Created:
              Updated:
              Resolved: