Skip to content

Commit

Permalink
[Zen2] Minor logging improvements (#36818)
Browse files Browse the repository at this point in the history
* Adds term number and greppable phrase 'coordinator becoming' to Coordinator
  mode changes
* Adds term and version to messages from the ClusterApplier about master
  changes
* Reduces some LeaderChecker messages to TRACE level
  • Loading branch information
DaveCTurner authored Dec 20, 2018
1 parent b42074c commit 52d34e4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ private void handleJoinRequest(JoinRequest joinRequest, JoinHelper.JoinCallback

void becomeCandidate(String method) {
assert Thread.holdsLock(mutex) : "Coordinator mutex not held";
logger.debug("{}: becoming CANDIDATE (was {}, lastKnownLeader was [{}])", method, mode, lastKnownLeader);
logger.debug("{}: coordinator becoming CANDIDATE in term {} (was {}, lastKnownLeader was [{}])",
method, getCurrentTerm(), mode, lastKnownLeader);

if (mode != Mode.CANDIDATE) {
mode = Mode.CANDIDATE;
Expand Down Expand Up @@ -440,7 +441,8 @@ void becomeLeader(String method) {
assert mode == Mode.CANDIDATE : "expected candidate but was " + mode;
assert getLocalNode().isMasterNode() : getLocalNode() + " became a leader but is not master-eligible";

logger.debug("{}: becoming LEADER (was {}, lastKnownLeader was [{}])", method, mode, lastKnownLeader);
logger.debug("{}: coordinator becoming LEADER in term {} (was {}, lastKnownLeader was [{}])",
method, getCurrentTerm(), mode, lastKnownLeader);

mode = Mode.LEADER;
joinAccumulator.close(mode);
Expand All @@ -461,7 +463,8 @@ void becomeFollower(String method, DiscoveryNode leaderNode) {
assert Thread.holdsLock(mutex) : "Coordinator mutex not held";
assert leaderNode.isMasterNode() : leaderNode + " became a leader but is not master-eligible";

logger.debug("{}: becoming FOLLOWER of [{}] (was {}, lastKnownLeader was [{}])", method, leaderNode, mode, lastKnownLeader);
logger.debug("{}: coordinator becoming FOLLOWER of [{}] in term {} (was {}, lastKnownLeader was [{}])",
method, leaderNode, getCurrentTerm(), mode, lastKnownLeader);

final boolean restartLeaderChecker = (mode == Mode.FOLLOWER && Optional.of(leaderNode).equals(lastKnownLeader)) == false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,15 @@ private class CheckScheduler implements Releasable {
@Override
public void close() {
if (isClosed.compareAndSet(false, true) == false) {
logger.debug("already closed");
logger.trace("already closed, doing nothing");
} else {
logger.debug("closed");
}
}

void handleWakeUp() {
if (isClosed.get()) {
logger.debug("closed check scheduler woken up, doing nothing");
logger.trace("closed check scheduler woken up, doing nothing");
return;
}

Expand Down Expand Up @@ -289,7 +289,7 @@ void leaderFailed() {
if (isClosed.compareAndSet(false, true)) {
transportService.getThreadPool().generic().execute(onLeaderFailure);
} else {
logger.debug("already closed, not failing leader");
logger.trace("already closed, not failing leader");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ private void applyChanges(UpdateTask task, ClusterState previousClusterState, Cl
if (nodesDelta.hasChanges() && logger.isInfoEnabled()) {
String summary = nodesDelta.shortSummary();
if (summary.length() > 0) {
logger.info("{}, reason: {}", summary, task.source);
logger.info("{}, term: {}, version: {}, reason: {}",
summary, newClusterState.term(), newClusterState.version(), task.source);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ protected void runTasks(TaskInputs taskInputs) {
if (nodesDelta.hasChanges() && logger.isInfoEnabled()) {
String nodeSummary = nodesDelta.shortSummary();
if (nodeSummary.length() > 0) {
logger.info("{}, reason: {}", summary, nodeSummary);
logger.info("{}, term: {}, version: {}, reason: {}",
summary, newClusterState.term(), newClusterState.version(), nodeSummary);
}
}

Expand Down

0 comments on commit 52d34e4

Please sign in to comment.