[JAVA-836] Only log on server availability state changes Created: 30/May/13  Updated: 31/Mar/15  Resolved: 05/Jun/13

Status: Closed
Project: Java Driver
Component/s: Monitoring
Affects Version/s: None
Fix Version/s: 2.11.3, 3.0.0

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by JAVA-632 Only print update error/warning once ... Closed
is duplicated by JAVA-655 Reduce excessive logging when replica... Closed
Related
Backwards Compatibility: Minor Change

 Description   

Currently the driver logs exceptions while trying to connect (in the background monitor thread) to a replica set member/mongos in two circumstances:

  1. when state goes from ok to !ok
  2. otherwise, approximately 10% of the time when state is !ok

The 10% rule is intended to reduce log flooding, but in a comment to this pull request, a commenter proposes a better idea: to log only the state changes, i.e.

  1. when state goes from ok to !ok
  2. when state goes from !ok to back to ok
  3. when the server state changes (like from primary to secondary, or has different tags.


 Comments   
Comment by Jeffrey Yemin [ 31/Mar/15 ]

Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released.

Comment by auto [ 12/Sep/13 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-836: Changed logic for logging of up and down servers. Now the background thread logs on every state change, which will reduce log spamming dramatically.
Branch: 2.11.x
https://github.com/mongodb/mongo-java-driver/commit/363401bb445cf65dc86509519342a6af2b85ea6f

Comment by Jeffrey Yemin [ 05/Jun/13 ]

This can be seen as backwards breaking for two reasons:

  1. if users were relying on the old behavior where there are more frequent log messages
  2. in 3.0.x branch, the log is named "org.mongodb.connection.monitor", whereas in master it's named "com.mongodb.ReplicaSetStatus"
Comment by Jeffrey Yemin [ 05/Jun/13 ]

The fix in the master branch logs when state transitions from

  • Connecting to either Connected or Unconnected
  • Connected to Unconnected
  • Unconnected to Connected

In the 3.0.x branch, it also logs when state transitions from

  • Connected to Connected but where the server description has changed, i.e. different tags

Also in 3.0, all the messages are logged at level INFO, whereas in master transitions to Unconnected are logged at level WARNING, while transitions to Connected are logged at INFO (to preserve backwards compatibility.

Comment by auto [ 05/Jun/13 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-836: Changed logic for logging of up and down servers. Now the background thread logs on every state change, which will reduce log spamming dramatically.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/8e02cd006d79acd1d0ae6604c2ee7537b250c044

Comment by auto [ 31/May/13 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-836: Refined server monitor thread to log every state change of the server description (except avg ping time change...).
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/e5c7b2552c8c240bd19c4cea91bc2a789d8ce76e

Comment by auto [ 30/May/13 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-836: Only log on state change in server monitor thread.
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/26de3689a19e0a52f84d10bc503112a890b30109

Generated at Thu Feb 08 08:53:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.