Java Driver
  1. Java Driver
  2. JAVA-836

Only log on server availability state changes

    Details

    • Type: Improvement Improvement
    • Status: Resolved Resolved
    • Priority: Major - P3 Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.11.3, 3.0.0
    • Component/s: Monitoring
    • Labels:
      None
    • Backward Breaking:
      Rarely
    • # Replies:
      6
    • Last comment by Customer:
      false

      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.

        Issue Links

          Activity

          Hide
          auto
          added a comment -

          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

          Show
          auto
          added a comment - 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
          Hide
          auto
          added a comment -

          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

          Show
          auto
          added a comment - 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
          Hide
          auto
          added a comment -

          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

          Show
          auto
          added a comment - 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
          Hide
          Jeff Yemin
          added a comment -

          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.

          Show
          Jeff Yemin
          added a comment - 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.
          Hide
          Jeff Yemin
          added a comment -

          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"
          Show
          Jeff Yemin
          added a comment - This can be seen as backwards breaking for two reasons: if users were relying on the old behavior where there are more frequent log messages in 3.0.x branch, the log is named "org.mongodb.connection.monitor", whereas in master it's named "com.mongodb.ReplicaSetStatus"
          Hide
          auto
          added a comment -

          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

          Show
          auto
          added a comment - 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

            People

            • Assignee:
              Unassigned
              Reporter:
              Jeff Yemin
              Participants:
              Last commenter:
              Jeff Yemin
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                32 weeks, 1 day ago
                Date of 1st Reply: