SDAM logs show the following every time a heartbeat is processed even when the cluster topology hasn't changed:
ongoDB-SDAM Information: 509 : {type: "SdamInformationEvent", message: "Updating stale electionId and setVersion: Updating the current (maxSetVersion, maxElectionId) tuple from (18, 7fffffff0000000000000003) to (18, 7fffffff0000000000000003) for replica set "atlas-o9yrji-shard-0" because replica set primary Unspecified/pl-0-us-east-1.ssvpo.mongodb.net:1025 sent (18, 7fffffff0000000000000003)—a larger (setVersion, electionId) tuple then the saved tuple, (18, 7fffffff0000000000000003)." }
This is due to a bug in ElectionInfo.Equals performing object comparison semantics rather than value comparison semantics. MultiServerCluster.cs line 379 contains the line:
if (!_maxElectionInfo.Equals(newMaxElectionInfo))
MultiServerCluster.ElectionInfo implements Equals as follows:
public override bool Equals(object obj) { var other = obj as ElectionInfo; return other != null && _setVersion == other.SetVersion && other.ElectionId == _electionId; }
Note that ElectionId is an object type and thus performs object comparison semantics. The following program always returns false even when electionId and setVersion are identical because the ElectionId objects are not the same object.
var setVersion1 = 42; var objectId1 = ObjectId.GenerateNewId(); var electionInfo1 = new ElectionInfo(setVersion1, new ElectionId(objectId1)); var electionInfo2 = new ElectionInfo(setVersion1, new ElectionId(objectId1)); Console.WriteLine(electionInfo1.Equals(electionInfo2));