Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding warning logs for rebuiding in memory chain #157

Merged
merged 5 commits into from
Nov 14, 2024

Conversation

Chengxuan
Copy link
Contributor

adding more logs to highlight the situation in which the in memory canonical chain is getting rebuilt

@Chengxuan Chengxuan requested a review from a team as a code owner November 13, 2024 17:59
@@ -84,6 +86,10 @@ func (ee *eventEnricher) filterEnrichEthLog(ctx context.Context, f *eventFilter,
}
}

if blockNumber < 0 || transactionIndex < 0 || logIndex < 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

overflow check as spotted by the linter

@Chengxuan Chengxuan marked this pull request as draft November 14, 2024 08:28
@Chengxuan
Copy link
Contributor Author

will add more debug logs

Signed-off-by: Chengxuan Xing <[email protected]>
@Chengxuan Chengxuan marked this pull request as ready for review November 14, 2024 08:54
@@ -426,7 +425,7 @@ func (bl *blockListener) rebuildCanonicalChain() *list.Element {
// It's possible the chain will change while we're doing this, and we fall back to the next block notification
// to sort that out.
if expectedParentHash != "" && mbi.parentHash != expectedParentHash {
log.L(bl.ctx).Debugf("Block listener canonical chain view rebuilt up to new re-org at block %d", nextBlockNumber)
log.L(bl.ctx).Warnf("rebuildCanonicalChain rebuild stopped at block: %d due to mismatch hash for parent block (%d): %s (expected: %s)", nextBlockNumber, nextBlockNumber-1, mbi.parentHash, expectedParentHash)
Copy link
Contributor

@peterbroadhurst peterbroadhurst Nov 14, 2024

Choose a reason for hiding this comment

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

Is this the change @Chengxuan ?

I see a move from regular logs otherwise, to including some function call semantics in the log names.
That's not a general approach this repo uses. There's pros and cons to it... but the main thing I'm concerned about is consistency.

Would you mind just making the change to the information that the logs contain?

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 switched them back for consistency. I personally found it's easier to have a unique ID to filter out logs.

From ops point of view, I need a string that have a good summary of what a function does when searching for logs, and I assume that's an important function of method names. Therefore, I prefer including function name in the collected logs. (no matter it's in log context or the message itself) other than inventing another way of summarize what the logs line is for.

Copy link
Contributor

Choose a reason for hiding this comment

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

We discussed offline that this is a good thing to work out separately, and needs to consider that the logging framework does provide this information (if you switch to JSON logging you'll see it)

Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

couple of small requests before this merges @Chengxuan

Signed-off-by: Chengxuan Xing <[email protected]>
@Chengxuan
Copy link
Contributor Author

Thanks @peterbroadhurst both comments addressed

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.81%. Comparing base (3c87e67) to head (7914431).
Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #157   +/-   ##
=======================================
  Coverage   99.81%   99.81%           
=======================================
  Files          25       27    +2     
  Lines        1635     1650   +15     
=======================================
+ Hits         1632     1647   +15     
  Misses          3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Chengxuan Xing <[email protected]>
@Chengxuan Chengxuan merged commit b561f24 into hyperledger:main Nov 14, 2024
6 checks passed
@Chengxuan Chengxuan deleted the add-warning-logs branch November 14, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants