Hi, thank you for your response. Currently there’s another team managing this microservice. This is what I gave them
mongo_uri=mongodb://user:pass@db1:27000,db2:27000,db3:27000/?replicaSet=replicaset-remote&authSource=admin&readPreference=secondary&maxStalenessSeconds=120
but in their code, they are using these options
mongo = await new MongoClient(mongo_uri, {
ignoreUndefined: true,
readPreference: ReadPreference.SECONDARY_PREFERRED,
}).connect()
I noticed there’s conflict in readPreference, but haven’t had the chance to fix it yet, due to role restriction. But do you think this may be the cause of the problem? Also this is the result from rs.status() if that helps. Thank you
{
"set" : "replicaset-remote",
"date" : ISODate("2022-07-12T11:36:15.052Z"),
"myState" : 1,
"term" : NumberLong(9),
"syncSourceHost" : "",
"syncSourceId" : -1,
"heartbeatIntervalMillis" : NumberLong(2000),
"majorityVoteCount" : 2,
"writeMajorityCount" : 2,
"votingMembersCount" : 3,
"writableVotingMembersCount" : 3,
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1657625775, 17),
"t" : NumberLong(9)
},
"lastCommittedWallTime" : ISODate("2022-07-12T11:36:15.046Z"),
"readConcernMajorityOpTime" : {
"ts" : Timestamp(1657625775, 17),
"t" : NumberLong(9)
},
"readConcernMajorityWallTime" : ISODate("2022-07-12T11:36:15.046Z"),
"appliedOpTime" : {
"ts" : Timestamp(1657625775, 17),
"t" : NumberLong(9)
},
"durableOpTime" : {
"ts" : Timestamp(1657625775, 17),
"t" : NumberLong(9)
},
"lastAppliedWallTime" : ISODate("2022-07-12T11:36:15.046Z"),
"lastDurableWallTime" : ISODate("2022-07-12T11:36:15.046Z")
},
"lastStableRecoveryTimestamp" : Timestamp(1657625753, 4),
"electionCandidateMetrics" : {
"lastElectionReason" : "stepUpRequestSkipDryRun",
"lastElectionDate" : ISODate("2021-12-26T10:07:29.763Z"),
"electionTerm" : NumberLong(9),
"lastCommittedOpTimeAtElection" : {
"ts" : Timestamp(1640513247, 1),
"t" : NumberLong(8)
},
"lastSeenOpTimeAtElection" : {
"ts" : Timestamp(1640513247, 1),
"t" : NumberLong(8)
},
"numVotesNeeded" : 2,
"priorityAtElection" : 1,
"electionTimeoutMillis" : NumberLong(10000),
"priorPrimaryMemberId" : 0,
"numCatchUpOps" : NumberLong(0),
"newTermStartDate" : ISODate("2021-12-26T10:07:29.778Z"),
"wMajorityWriteAvailabilityDate" : ISODate("2021-12-26T10:07:32.894Z")
},
"members" : [
{
"_id" : 0,
"name" : "",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 17113068,
"optime" : {
"ts" : Timestamp(1657625775, 17),
"t" : NumberLong(9)
},
"optimeDate" : ISODate("2022-07-12T11:36:15Z"),
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"electionTime" : Timestamp(1640513249, 1),
"electionDate" : ISODate("2021-12-26T10:07:29Z"),
"configVersion" : 3,
"configTerm" : 9,
"self" : true,
"lastHeartbeatMessage" : ""
},
{
"_id" : 1,
"name" : "",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 15477834,
"optime" : {
"ts" : Timestamp(1657625773, 151),
"t" : NumberLong(9)
},
"optimeDurable" : {
"ts" : Timestamp(1657625773, 151),
"t" : NumberLong(9)
},
"optimeDate" : ISODate("2022-07-12T11:36:13Z"),
"optimeDurableDate" : ISODate("2022-07-12T11:36:13Z"),
"lastHeartbeat" : ISODate("2022-07-12T11:36:13.314Z"),
"lastHeartbeatRecv" : ISODate("2022-07-12T11:36:14.588Z"),
"pingMs" : NumberLong(0),
"lastHeartbeatMessage" : "",
"syncSourceHost" : "",
"syncSourceId" : 0,
"infoMessage" : "",
"configVersion" : 3,
"configTerm" : 9
},
{
"_id" : 2,
"name" : "",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 15477759,
"optime" : {
"ts" : Timestamp(1657625774, 7),
"t" : NumberLong(9)
},
"optimeDurable" : {
"ts" : Timestamp(1657625774, 7),
"t" : NumberLong(9)
},
"optimeDate" : ISODate("2022-07-12T11:36:14Z"),
"optimeDurableDate" : ISODate("2022-07-12T11:36:14Z"),
"lastHeartbeat" : ISODate("2022-07-12T11:36:14.093Z"),
"lastHeartbeatRecv" : ISODate("2022-07-12T11:36:14.830Z"),
"pingMs" : NumberLong(0),
"lastHeartbeatMessage" : "",
"syncSourceHost" : "",
"syncSourceId" : 1,
"infoMessage" : "",
"configVersion" : 3,
"configTerm" : 9
}
],
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1657625775, 17),
"signature" : {
"hash" : BinData(0,"udjGeYIefRN886XFy4HW8chzJeY="),
"keyId" : NumberLong("7086458178816180233")
}
},
"operationTime" : Timestamp(1657625775, 17)
}