mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 09:11:37 +00:00
Reduce log noise #34729
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!34729
Loading…
Reference in a new issue
No description provided.
Delete branch "202603-logerror"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This set of changes reduces some of the exaggerated logging that was introduced in #29236 when "error()" logging was upgraded from
LogPrintf(akaLogInfo) toLogError. It also introducesLogWarnThenDebug()which duplicates the behaviour of #34549 which issues a warning the first time the log line is hit, but downgrades that to categorized debug messages afterwards. This function is used for failures that are likely caused by system configuration problems (so likely degrade the node's functionality and warrant admin attention) but are triggered by remote activity and thus could occur frequently.The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
util::Expectedby yuvicc)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.
See #30348 for further background; I think the changes here should be able to stand on their own merits. I haven't addressed cases where there's ambiguity between LogWarning and LogError here, but if there are other current cases where things are at Warning/Error and should be Info, or at Warning/Error/Info and should be Debug, happy to add them to this PR.
ACK c665935d02b633032147e58436e3a1c6511d64f3
This is a good improvement on the amount of functional code dedicated to logging. Also, the
LogWarnThenDebuglog will be useful in future cases to help avoid log noiseAdded two comments about potentially adding
BCLog::VALIDATIONto the two validation logs touchedLogWarning doesn't accept a filter category because it isn't filterable.
LogWarning doesn't accept a filter category because it isn't filterable.
Ahh ya my bad. Also, it makes sense to have only debug logs to be filterable since warnings and errors should always be seen.
Code review ACK c665935d02b633032147e58436e3a1c6511d64f3, Concept -0. Changes here seem logical overall, and I left comments the few places where I had concerns. The
LogWarnThenDebugmacro also seems cool and potentially useful more places.The thing I don’t like about this change is that it makes it harder to see if messages are errors or warnings or normal notifications. Being able to see
[error]and[warning]tags is a nice feature that is unfortunate to lose. 1In an ideal world I would use
LogWarningandLogErrormacros more places rather than fewer. I would also makeLogWarningandLogErrormessages configurable and not always shown, and add aLogCriticallevel for truly critical messages that should always be shown even when debug logging is off.That said, this PR seems fine overall: some positives, some negatives, and the code changes look ok.
Note that a message’s error/warning/info status is orthogonal to its priority. A message could describe a normal condition (info), an unexpected condition (warning), or a failure condition (error), and any of these messages could have high or low priority depending how important the information is, whether the condition is temporary or permanent, what side effects it could lead to, and whether it might require manual intervention. ↩︎
In commit "script: Lower level of oversized redeemScript log, push errors to callers" (c02d58966796c80a37d745957e37d5134d0c093d)
It seems good to throw an error here though text of this message doesn't seem ideal. Redeemscript blob is potentially large and earler logged message seems more helpful (though I'm not sure if logs are shown in bitcoin-tx so it might also be useless). Might want to add another TODO comment here to improve
In commit "netbase: Tidy up logging levels" (436bc942d362aefbf7315c73f74d032dcb75f435)
Maybe prefix this with
Error:to indicate a problem has occurred and distinguish this from informational debug messagesWould suggest the same for other some messages below that aren't clearly labeled as error or failures.
In commit "netbase: Reduce levels of socks5 error logging" (75674718fd35102be0db288802c7dc3af57ca986)
If this is an error communicating with the proxy server (as opposed to an error with the proxy server making a remote connection), it would seem potentially important for the user to know about so they can fix the problem with the server. Hiding this could make problems harder to diagnose, and it might be better to keep the previous level
In commit "netbase: Tidy up logging levels" (436bc942d362aefbf7315c73f74d032dcb75f435)
This change seems ok, but if the goal in the commit message is to use higher levels for errors "that may be due to system misconfiguration" I don't know why this socket error would be more likely to be the result of misconfiguration than SO_NOSIGPIPE above, or if something else account for the difference like this error being considered more severe?
In commit "netbase: Reduce levels of socks5 error logging" (75674718fd35102be0db288802c7dc3af57ca986)
I’m not sure
LogWarnThenDebug()is the best fit here. Compared to the earlier uses in this commit and the previous one, this seems less like a persistent configuration problem and more like something that could be intermittent, e.g. due to hitting resource limits.In that case, warning exactly once and never again may hide recurring failures. It would seem better to have a rate limit and show the error once per hour or once per day while it is still occurring, not to just show it once and never again for the lifetime of the process. Absent that, keeping this at info/warning/error level might be safer.
The
SO_NOSIGPIPEerror is marked as "continuing anyway", rather than immediately failing the connection, which seems fairly straightforwardly less severe.In commit 436bc942d362aefbf7315c73f74d032dcb75f435
I'm a bit confused when you are choosing Debug and when WarnThenDebug in this commit. What is the difference between these cases?
Proxy::Connectfailing means you can't connect to the proxy you've configured, which seems likely to be a fairly serious problem for your node, and that error is likely the thing you need to see;ConnectDirectlyfailing might also be a severe problem, but it might also just be that you're trying to connect over ipv6 because your node says "why not?" but your OS says "no way", which is not really problematic at all. Note thatCreateSockisCreateSockOSwhich mostly hasLogWarnThenDebugbefore it returns nullptr as well.Not particularly wedded to any particular choices here, these were just my best guesses.
Thanks for elaborating. Makes sense to me.
ACK 5359a99eb9b5bd442daee6c35d133ee5ea9f6583
The changes make sense to me, Concept ACK.
I would also be fine merging as-is, but please consider the few remaining comments.
Nit: the
Logprefix is kinda redundant, but it is consistent with the existing functions, so in this PR it makes sense to keep it (maybe in a follow-up we could remove it).yeah, maybe something like:
We've added the index names, maybe we could add a bit more info:
and the later ones:
and
Commit message nit:
ComputeUTXOStates->ComputeUTXOStatsIt seems to me that every single caller checks the result, usually returning an
Erroror throwing, so demoting this makes sense. Maybe we could extend the commit message with this info.For consistency with other similar "unable to read" messages, and to continue our
__func__removals, maybe we could adjust this to something like:Given that the original authors thought these should be errors, we could add short commit message explanations to clarify why these (expected?) conditions are no longer treated as serious errors. Obviously, no need to overdo it, but maybe add a short summary of your GitHub comments about the categories and constraints you've considered.
Not sure about this. Wouldn't that just blur the line between what's an error, what's a warning, and what's info and debug? Wouldn't
LogWarnThenDebugsuffice for that case?Slightly unrelated, but some connection-management diagnostics outside
netbasemay still be repeated in logs for ordinary retries, e.g.github.com/bitcoin/bitcoin@10ca73c02c/src/net.cpp (L394)Maybe we could also change this one to something like:
Since we're already modifying it, maybe we could make it consistent with other similar calls and log the error:
nit: The current
_warnedflag names the second state, so the first branch has to be expressed as a negation.Could this instead track whether the call site should still warn? That keeps the first-warning branch first and makes the condition read directly:
nit1: The formatting seems a bit off compared to
detail_LogIfCategoryAndLevelEnabled, by one space per indentation level.nit2: We could use
static std::atomic_bool _warned{false}here instead and add#include <atomic>.nit3:
whileis not a function, so I added a space after it.Could we test the behavior of this newly added logger with a simple unit test, something like:
The original authors tagged them with "ERROR:" via the
error()helper, which was accurate -- they're not things that are expected to happen in normal usage, anderror()just added some log text and an early exit. That was changed to invokeLogErrorin #29236 which was not correct per the definition of that function in the docs, and this PR just corrects that.Code review ACK 5359a99eb9b5bd442daee6c35d133ee5ea9f6583. Concept -0 as explained in previous review (because this makes it harder to tell when errors are happening). No changes since previous review other than rebase.
re: https://github.com/bitcoin/bitcoin/pull/34729#discussion_r3225902706
I just think we should make it easy to distinguish failure messages from status messages. So I'd agree
LogWarnThenDebugwould be an improvement because it would provide a clearer indication that something is wrong.But I think you should be allowed to use the word "Error" even if you are not literally calling the
LogErrormacro. I've said elsewhere theLogErrormacro is poorly named for what it's it's currently intended to be used for (severe errors causing the node to not function), and think a name likeLogCriticalwould be better.@ajtowns do you want to address the remaining comments here?
I think it's clearer as is -- the condition is that if we haven't already warned, we warn, and if we have we do a debug log. The warn goes in the first branch because it's the first thing we do, and the condition is negated, because of the "not" in "haven't already warned".
Taken.
We already had #29236 being overzealous in equating "error" with
LogError, so I don't think it would be smart to set things up for that to happen again. Combining and renaming LogError/LogWarning to LogAlert/LogCritical/LogKablooie/whatever (eg #34730) might make the distinction clearer and reduce the risk of confusion though.As far as I can see, you'll only get an this error in bitcoin-tx if you deliberately feed it an overly large redeemscript via the
setregister command, so if you get ~14 lines of error message because you deliberately fed it ~14 lines of redeemscript, that doesn't seem very problematic.bitcoin-tx doesn't show log lines (it doesn't call
StartLogging).Rebased, addressed some feedback (LogWarnThenDebug test particularly). I think non-trivial improvements to the wording/information provided in these (and related) log messages are better left for a separate PR.
Re-ACK 8d60c1428507921d9dd70c9840c41e447649268f
lightly tested ACK 8d60c1428507921d9dd70c9840c41e447649268f
Not all of the comments have been replied to, but I assumed the change is ready for re-review anyway.
I have slightly different takes on a few decisions here, but no strong opinion either way. I focused mostly on correctness, style, utility, and consistency - the world is a slightly better place after this change.
I'm personally fine with merging as-is, but would be interested in @ryanofsky's opinion here, given how many PRs are in conflict with this one.
nit:
redeemScripts->redeemScriptnit2: would probably be interesting to show the invalid size
Yes, my point was avoiding double negation:
Seems to me
#include <atomic>is missing hereHmmm, something's off here.
First, change doesn't seem like "log noise reduction" - but that could be fine if it's setting up a follow up -, but the test is actually passing with:
i.e. without the call:
The reason is that
keystore.AddKeyPubKeycallsImplicitlyLearnRelatedKeyScriptswhich just overrides (or populates if the above patch is taken)mapScriptswith the script.It seems to me removing the line is a simpler fix that addin a check.
(cc: @instagibbs)
Code review ACK 8d60c1428507921d9dd70c9840c41e447649268f. Approach -0 because this drops
[error]and[warning]tags so now the log messages are harder to interpret. IMO, a better approach would keep[error]and[warning]levels but make them conditional, using a[critical]level for actually critical messages.Since previous review, only changes are rebasing and adding test. I think the PR may be RFM if review comments are replied to and there aren't other objections.
🐙 This pull request conflicts with the target branch and needs rebase.
The change is just to ensure that the return value isn't discarded (due to the
nodiscardaddition), and because the inner_script is known and doesn't exceed the limit, we can rely on the return value being true and useBOOST_CHECKrather than(void).The primary change here is reducing
LogErrorfor something that isn't going to abort a node or subsystem toLogInfo, but even that is overkill, so the[[nodiscard]]and comment set things up so the log message could be removed entirely in the future.🚧 At least one of the CI tasks failed.
Task
iwyu: https://github.com/bitcoin/bitcoin/actions/runs/31904474132/job/95060048027LLM reason (✨ experimental): CI failed because the IWYU include-check reported a failure and caused formatting/IWYU changes (no-contentful-changes checks didn’t match), leading to an intentional
falseexit.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
Base:
65896ac58ea63e29ad19d41b492e37f8722ac715Head:
91f8b365e7e7887e59240651c2c76b1a64071233Design and approach
Preserve visible diagnostics when socket creation fails (src/netbase.cpp:661, head)
When
CreateSockfails, this branch logs only at NET debug level, even thoughmanual_connectionis available andLogConnectFailureretains Info-level messages for manual attempts. Manual connections reach this path, including TCP proxy connections that callConnectDirectlywithmanual_connection=true. In particular,CreateSockOSreturns null without logging ifsocket()returnsINVALID_SOCKET, leaving this branch as the only diagnostic. Preserve a default-visible explanation for explicitly requested connections, and consider whether raw socket-allocation failures should receive the first-warning treatment used for other socket-setup failures. No concrete current occurrence ofsocket()returningINVALID_SOCKETwas identified, so the production impact is unconfirmed.Keep visible diagnostics for SOCKS5 protocol failures (src/netbase.cpp:419, head)
If the connected endpoint responds with a non-SOCKS5 version, this branch emits only PROXY debug output and returns failure.
ConnectThroughProxyadds no default-level follow-up, and the same handshake path serves manually requested proxied connections;Socks5does not receive the manual-connection distinction. Keep a first-visible diagnostic for clear protocol or configuration failures such as a wrong-version response, while leaving expected destination timeouts quiet. No current production response with a wrong SOCKS version was identified, so its real-world frequency and impact are unconfirmed.Keep destination connection failures in the NET category (src/netbase.cpp:479, head)
This SOCKS5 CONNECT reply reports failure to connect to the destination peer, as the adjacent comment notes, but the message moved from NET to PROXY. Users who enable
-debug=netwill no longer see the reason unless they also enable PROXY, andConnectThroughProxyadds no NET diagnostic for the handshake failure. Keep the reduced-severity message in NET and reserve PROXY for proxy-handshake failures. No specific current production proxy reply with a failure code was identified, so the frequency of this impact is unconfirmed.Review coverage was incomplete. The archaeology review had incomplete evidence. The adversarial review had incomplete evidence.
Full review report
lightweight re-ACK
91f8b365e7Re-reviewed the diff and changes and previous suggestions, I don't have strong opinions, my remaining comments are non-blocking.
K, we can also fix it in a followup
Re-ACK
91f8b365e7ACK
91f8b365e7