serverStatus readPreferenceCounters internal metric includes commands run through mongos

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Replication
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      A user-initiated command that runs through mongos bumps up the "internal" counter on mongod. But this counter also includes system operations, so it's hard for a user to look at this metric and know how many of their operations actually used a particular read preference.

      For example:

      // "internal" value at first is 57. We run this by connecting directly to the primary node.
      MongoDB Enterprise shard-rs0:PRIMARY> db.serverStatus().readPreferenceCounters.executedOnPrimary.primary
      { "internal" : NumberLong(57), "external" : NumberLong(8) }
      
      // Run a "find" through mongos.
      MongoDB Enterprise mongos> db.vkcoll.find().readPref("primary")
      
      // "internal" value has increased by one to 58. External value is the same.
      MongoDB Enterprise shard-rs0:PRIMARY> db.serverStatus().readPreferenceCounters.executedOnPrimary.primary
      { "internal" : NumberLong(58), "external" : NumberLong(8) }
      

      "External" is only bumped when a user connects directly to mongod.

      // "external" value is 8.
      MongoDB Enterprise shard-rs0:PRIMARY> db.serverStatus().readPreferenceCounters.executedOnPrimary.primary
      { "internal" : NumberLong(58), "external" : NumberLong(8) }
      
      // Run "find" directly on the primary.
      MongoDB Enterprise shard-rs0:PRIMARY> db.vkcoll.find().readPref("primary")
      ...
      
      // "external" value increases to 9. "internal" value stays the same.
      MongoDB Enterprise shard-rs0:PRIMARY> db.serverStatus().readPreferenceCounters.executedOnPrimary.primary
      { "internal" : NumberLong(58), "external" : NumberLong(9) }
      

      See links.

            Assignee:
            Unassigned
            Reporter:
            Vishnu Kaushik
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: