[SERVER-16793] when running db.getSlaveReplicationInfo() on secondary it treats "self" as "master" Created: 09/Jan/15  Updated: 23/Jan/15  Resolved: 15/Jan/15

Status: Closed
Project: Core Server
Component/s: Replication, Shell
Affects Version/s: 2.5.1, 2.8.0-rc4
Fix Version/s: 3.0.0-rc6

Type: Bug Priority: Minor - P4
Reporter: Asya Kamsky Assignee: Matt Dannenberg
Resolution: Done Votes: 0
Labels: polish
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

When db.printReplicationInfo() is run on secondary, it call db.printSlaveReplicationInfo() which is written to only work correctly when called on a primary as it uses "self" as "master" in getMaster():

    function getMaster(members) {
        var found;
        members.forEach(function(row) {
            if (row.self) {
                found = row;
                return false;
            }
        });
 
        if (found) {
            return found;
        }
    };

This is wrong in that it (a) tests "self" when trying to getMaster. If it finds "self" it ends up returning that member.

Now printSlaveReplicationInfo is setting this node's optime to compare other nodes against and ends up printing things like:

  -308 secs (-0.09 hrs) behind the primary 

Either it should find primary correctly (change check of "self" to be "state"==1 check) or it should print "behind" me rather than "behind the primary"



 Comments   
Comment by Githook User [ 15/Jan/15 ]

Author:

{u'username': u'dannenberg', u'name': u'matt dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: SERVER-16793 properly obtain primary in printSlaveReplicationInfo and change output to reflect when no primary is present
Branch: master
https://github.com/mongodb/mongo/commit/57806db0234321b9b88a74e013d952104e0c459a

Generated at Thu Feb 08 03:42:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.