1

We have a mongodb replica set with 3 nodes (db01-03) running as replica set "rs0".

When getting hosts info via MongoClient::getHosts(), the primary server SOMETIMES is being reported twice, once as part of the rs0, once standalone (so it seems?):

{
  "db01.example.com:27017;rs0;...": {
    "host": "db01.example.com",
    "port": 27017,
    "health": 1,
    "state": 2,
    "ping": 0,
    "lastPing": 1475144757
  },
  "db02.example.com:27017;rs0;........": {
    "host": "db02.example.com",
    "port": 27017,
    "health": 1,
    "state": 1,
    "ping": 0,
    "lastPing": 1475144757
  },
  "db03.example.com:27017;rs0;.......": {
    "host": "db03.example.com",
    "port": 27017,
    "health": 1,
    "state": 2,
    "ping": 0,
    "lastPing": 1475144757
  },
  "db02.example.com:27017;-;.......": {
    "host": "db02.example.com",
    "port": 27017,
    "health": 1,
    "state": 1,
    "ping": 0,
    "lastPing": 1475143739
  }
}

Why does this happen, is this intentional/accidental or something we should be concerned about?

Problem is, that our monitoring regularily compares "reported hosts" vs "expected hosts" and we receive alerts since 4 !== 3.

PS:Of course we could fix the alerts by comparing $actual<$expected; that is not the question, but:

Why is the primary sometimes shown twice?

Vince Bowdren
  • 8,326
  • 3
  • 31
  • 56
Xosofox
  • 840
  • 1
  • 7
  • 21

0 Answers0