Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Jun 9, 2024

This picks up the first commit from #29231, but extends it to also cover cases that were missed in it.

As per https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#logging, LogError should be used for severe problems that require the node to shut down.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 9, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK stickies-v, kevkevinpal, achow101
Stale ACK BrandonOdiwuor

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #29641 (scripted-diff: Use LogInfo/LogDebug over LogPrintf/LogPrint by maflcko)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Contributor

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

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

ACK b90f1c3 - more consistent logging

@@ -6303,7 +6303,7 @@ bool ChainstateManager::ValidatedSnapshotCleanup()
fs::path p_old,
fs::path p_new,
const fs::filesystem_error& err) {
LogPrintf("Error renaming path (%s) -> (%s): %s\n",
LogError("[snapshot] Error renaming path (%s) -> (%s): %s\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: since we're calling GetNotifications().fatalError() next, I think this log line can just be removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

My understanding is that the notification does not include err.what(), so the debug log in this line is still needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just merge them?

git diff on b90f1c3
diff --git a/src/validation.cpp b/src/validation.cpp
index 89aa84a551..ac95824443 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -6303,12 +6303,10 @@ bool ChainstateManager::ValidatedSnapshotCleanup()
                                    fs::path p_old,
                                    fs::path p_new,
                                    const fs::filesystem_error& err) {
-        LogError("[snapshot] Error renaming path (%s) -> (%s): %s\n",
-                  fs::PathToString(p_old), fs::PathToString(p_new), err.what());
         GetNotifications().fatalError(strprintf(_(
-            "Rename of '%s' -> '%s' failed. "
+            "[snapshot] Rename of '%s' -> '%s' failed: %s. "
             "Cannot clean up the background chainstate leveldb directory."),
-            fs::PathToString(p_old), fs::PathToString(p_new)));
+            fs::PathToString(p_old), fs::PathToString(p_new), err.what()));
     };
 
     try {

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is fine to have this log, but happy to review a separate pull removing it :)

Copy link
Member Author

Choose a reason for hiding this comment

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

This reminded me to change the two other log lines before fatalError to use the error level. So I pushed that other change in the last push.

@maflcko maflcko force-pushed the 2406-logError branch 2 times, most recently from faa3f8a to 2222f25 Compare June 10, 2024 10:43
@stickies-v
Copy link
Contributor

re-ACK 2222f25

As per doc/developer-notes#logging, LogError should be used for
severe problems that require the node to shut down.

Co-Authored-By: stickies-v <stickies-v@protonmail.com>
Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor left a comment

Choose a reason for hiding this comment

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

ACK 2222f25 - Replacing LogPrintf with Logerror to enhance critical error logging

@stickies-v
Copy link
Contributor

re-ACK fae3a1f, I'm ~0 on the latest force push as user_error was already logged at the right level through GetNotifications().fatalError(user_error); so I'd be in favour of deduplicating/cleaning up this logging logic but can be done in follow-up.

@maflcko
Copy link
Member Author

maflcko commented Jun 12, 2024

user_error was already logged at the right level through GetNotifications().fatalError(user_error);

Happy to review a follow-up for the two cases (#30255 (comment)). For now I think it is risk-free and more consistent to log the fatal error twice in the error log category.

@kevkevinpal
Copy link
Contributor

ACK fae3a1f

agree with #30255 (comment) but that should be good for a follow up

@achow101
Copy link
Member

ACK fae3a1f

@achow101 achow101 merged commit 538497b into bitcoin:master Jun 14, 2024
@maflcko maflcko deleted the 2406-logError branch June 21, 2024 09:00
@bitcoin bitcoin locked and limited conversation to collaborators Jun 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants