Skip to content

Commit f0f1090

Browse files
authored
Remove redundant logging of maxElectionId/maxSetVersion (#902)
JAVA-4550
1 parent 9884e19 commit f0f1090

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

driver-core/src/main/com/mongodb/internal/connection/AbstractMultiServerCluster.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,14 @@ private boolean handleReplicaSetMemberChanged(final ServerDescription newDescrip
252252
}
253253

254254
if (newDescription.isPrimary()) {
255-
if (isNonStalePrimary(newDescription.getElectionId(), newDescription.getSetVersion())) {
256-
LOGGER.info(format("Setting max election id to %s and max set version to %d from replica set primary %s",
257-
newDescription.getElectionId(), newDescription.getSetVersion(), newDescription.getAddress()));
258-
maxElectionId = newDescription.getElectionId();
259-
maxSetVersion = newDescription.getSetVersion();
255+
if (isNonStalePrimary(newDescription.getElectionId(), newDescription.getSetVersion())) {
256+
if (nullSafeCompareTo(newDescription.getElectionId(), maxElectionId) != 0
257+
|| nullSafeCompareTo(newDescription.getSetVersion(), maxSetVersion) != 0) {
258+
LOGGER.info(format("Setting max election id to %s and max set version to %d from replica set primary %s",
259+
newDescription.getElectionId(), newDescription.getSetVersion(), newDescription.getAddress()));
260+
maxElectionId = newDescription.getElectionId();
261+
maxSetVersion = newDescription.getSetVersion();
262+
}
260263
} else {
261264
LOGGER.info(format("Invalidating potential primary %s whose (set version, election id) tuple of (%d, %s) "
262265
+ "is less than one already seen of (%d, %s)",

0 commit comments

Comments
 (0)