Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Additional logging details for IBFT #650

Merged
merged 13 commits into from
Jan 25, 2019
Merged

Conversation

jframe
Copy link
Contributor

@jframe jframe commented Jan 24, 2019

PR description

This adds some additional logging in IBFT. It is mostly centred on logging details in the state machine.
I'm also name=value pairs for the additional data that is being logged both so it is easier to parse (both manually and with logging tools).
Also lowered some of the existing INFO logging levels to DEBUG.

Fixed Issue(s)

@jframe jframe requested review from rain-on and CjHare January 24, 2019 05:14
Copy link
Contributor

@CjHare CjHare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -75,6 +75,11 @@ public void send(final MessageData message, final Collection<Address> blackList)

private void sendMessageToSpecificAddresses(
final Collection<Address> recipients, final MessageData message) {
LOG.trace(
"Sending message to peers messageCode={} messageData={} recipients={}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the message data contained might be useful - but I suspect that given its a byte array, our ability to deconstruct it might be ... hard.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be difficult to deconstruct, I was considering leaving it out. thinking about it more I don't think it is useful especially since the raw packet is already logged by netty.

@@ -84,7 +89,10 @@ private void sendMessageToSpecificAddresses(
try {
connection.sendForProtocol(PROTOCOL_NAME, message);
} catch (final PeerNotConnected peerNotConnected) {
LOG.trace("Lost connection to a validator.");
LOG.trace(
"Lost connection to a validator. remoteAddress={} peerInfo={}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to know when we gain/lose validators, we should log that in the add/remove? An error here means we literally ran into the someone disconnected between creating the stream and getting to their turn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do want to know when we gain/remove validators. I've just added additional details to the existing log so we know who peer got disconnected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should log that in the add/remove - not in this exception - in fact, this exception BORDERLINE doesn't need info in it...

actionOrBufferMessage(
signedPayload, currentRound::handleProposalMessage, RoundState::setProposedBlock);
}

public void handlePreparePayload(final SignedData<PreparePayload> signedPayload) {
LOG.info("Received a prepare Payload.");
LOG.debug("Received a prepare Payload.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capital P-repare (to match Proposal above)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

actionOrBufferMessage(
signedPayload, currentRound::handlePrepareMessage, RoundState::addPrepareMessage);
}

public void handleCommitPayload(final SignedData<CommitPayload> payload) {
LOG.info("Received a commit Payload.");
LOG.debug("Received a commit Payload.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capital C-ommit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -191,7 +196,7 @@ public void handleRoundChangePayload(final SignedData<RoundChangePayload> signed

final MessageAge messageAge = determineAgeOfPayload(signedPayload.getPayload());
if (messageAge == PRIOR_ROUND) {
LOG.info("Received RoundChange Payload for a prior round.");
LOG.info("Received RoundChange Payload for a prior round. targetRound={}", targetRound);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably trace - i.e. we really don't care too much about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think more debug than trace. could be useful for troubleshooting issues. changing to debug.

@@ -189,7 +201,7 @@ private boolean updateStateWithProposedBlock(final SignedData<ProposalPayload> m
if (blockAccepted) {
// There are times handling a proposed block is enough to enter prepared.
if (wasPrepared != roundState.isPrepared()) {
LOG.info("Sending commit message.");
LOG.info("Sending commit message. round={}", roundState.getRoundIdentifier());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trace

@@ -212,7 +224,7 @@ private void peerIsPrepared(final SignedData<PreparePayload> msg) {
final boolean wasPrepared = roundState.isPrepared();
roundState.addPrepareMessage(msg);
if (wasPrepared != roundState.isPrepared()) {
LOG.info("Sending commit message.");
LOG.info("Sending commit message. round={}", roundState.getRoundIdentifier());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug? (maybe trace ...)

@@ -97,7 +97,7 @@ public RoundChangeManager(
final SignedData<RoundChangePayload> msg) {

if (!isMessageValid(msg)) {
LOG.info("RoundChange message was invalid.");
LOG.error("RoundChange message was invalid.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not an error ... just can't use the message (typically pantheon treats malformed packets as bad, but not terrible, as there are so many actors out there ... its kinda normal)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if its normal i'll make it info level.

prepared =
(preparePayloads.size() >= prepareMessageCountForQuorum(quorum))
&& proposalMessage.isPresent();
final long prepareQuorum = prepareMessageCountForQuorum(quorum);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should get moved into the class constructor (i.e. can be calculated at startup).

@@ -79,13 +82,15 @@ public boolean setProposedBlock(final SignedData<ProposalPayload> msg) {
public void addPrepareMessage(final SignedData<PreparePayload> msg) {
if (!proposalMessage.isPresent() || validator.validatePrepareMessage(msg)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-reading this conditional kinda hurt my head, its correct, but not obviously.
May be a symptom of the design rather than the code ... but ... :/
Rather see it say "If(Proposal.isPresent() && isValid) store; else if(!Proposal) store.

@@ -75,6 +75,11 @@ public void send(final MessageData message, final Collection<Address> blackList)

private void sendMessageToSpecificAddresses(
final Collection<Address> recipients, final MessageData message) {
LOG.trace(
"Sending message to peers messageCode={} messageData={} recipients={}",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be difficult to deconstruct, I was considering leaving it out. thinking about it more I don't think it is useful especially since the raw packet is already logged by netty.

@@ -84,7 +89,10 @@ private void sendMessageToSpecificAddresses(
try {
connection.sendForProtocol(PROTOCOL_NAME, message);
} catch (final PeerNotConnected peerNotConnected) {
LOG.trace("Lost connection to a validator.");
LOG.trace(
"Lost connection to a validator. remoteAddress={} peerInfo={}",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do want to know when we gain/remove validators. I've just added additional details to the existing log so we know who peer got disconnected.

actionOrBufferMessage(
signedPayload, currentRound::handleProposalMessage, RoundState::setProposedBlock);
}

public void handlePreparePayload(final SignedData<PreparePayload> signedPayload) {
LOG.info("Received a prepare Payload.");
LOG.debug("Received a prepare Payload.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

actionOrBufferMessage(
signedPayload, currentRound::handlePrepareMessage, RoundState::addPrepareMessage);
}

public void handleCommitPayload(final SignedData<CommitPayload> payload) {
LOG.info("Received a commit Payload.");
LOG.debug("Received a commit Payload.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -191,7 +196,7 @@ public void handleRoundChangePayload(final SignedData<RoundChangePayload> signed

final MessageAge messageAge = determineAgeOfPayload(signedPayload.getPayload());
if (messageAge == PRIOR_ROUND) {
LOG.info("Received RoundChange Payload for a prior round.");
LOG.info("Received RoundChange Payload for a prior round. targetRound={}", targetRound);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think more debug than trace. could be useful for troubleshooting issues. changing to debug.

@@ -99,11 +104,13 @@ public void startRoundWith(

SignedData<ProposalPayload> proposal;
if (!latestCertificate.isPresent()) {
LOG.info("Multicasting NewRound with new block.");
LOG.info("Multicasting NewRound with new block. round={}", roundState.getRoundIdentifier());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with that. done.

final Block block = blockCreator.createBlock(headerTimestamp);
proposal = messageFactory.createSignedProposalPayload(getRoundIdentifier(), block);
} else {
LOG.info("Multicasting NewRound from PreparedCertificate.");
LOG.info(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll make this trace too

@@ -132,14 +139,19 @@ public void startRoundWith(
blockHeader, extraDataToPublish));
final BlockHeader newHeader = headerBuilder.buildBlockHeader();
final Block newBlock = new Block(newHeader, block.getBody());
LOG.debug(
"Created proposal from prepared certificate blockHeader={} extraData={}",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch. I was going to include the block number as well. don't think it's needed as this is included in the block header.
done.

@@ -169,12 +181,12 @@ private void actionReceivedProposal(final SignedData<ProposalPayload> msg) {
}

public void handlePrepareMessage(final SignedData<PreparePayload> msg) {
LOG.info("Received a prepare message.");
LOG.info("Received a prepare message. round={}", roundState.getRoundIdentifier());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure on these. might belong at debug level. is this and the handle logs useful for debugging or is a bit over the top?

@@ -97,7 +97,7 @@ public RoundChangeManager(
final SignedData<RoundChangePayload> msg) {

if (!isMessageValid(msg)) {
LOG.info("RoundChange message was invalid.");
LOG.error("RoundChange message was invalid.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if its normal i'll make it info level.

@jframe jframe merged commit 752bfd6 into PegaSysEng:master Jan 25, 2019
@jframe jframe deleted the ibft_logging branch January 25, 2019 06:21
rain-on pushed a commit to rain-on/pantheon that referenced this pull request Jan 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants