-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Move log messages: tx enqueue to mempool, allocation to blockstorage #27277
base: master
Are you sure you want to change the base?
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
cb37465
to
f2c7d95
Compare
Still investigating the linter issue… (update: figured it out)
|
f2c7d95
to
8de17cd
Compare
src/validationinterface.cpp
Outdated
LOG_EVENT(fmt, local_name, __VA_ARGS__); \ | ||
event(); \ | ||
}); \ | ||
#define ENQUEUE_AND_LOG_EVENT(category, event, fmt, name, ...) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8de17cd
to
4eff439
Compare
src/flatfile.cpp
Outdated
@@ -66,7 +66,7 @@ size_t FlatFileSeq::Allocate(const FlatFilePos& pos, size_t add_size, bool& out_ | |||
if (CheckDiskSpace(m_dir, inc_size)) { | |||
FILE *file = Open(pos); | |||
if (file) { | |||
LogPrint(BCLog::VALIDATION, "Pre-allocating up to position 0x%x in %s%05u.dat\n", new_size, m_prefix, pos.nFile); | |||
LogPrint(BCLog::BLOCKSTORE, "Pre-allocating up to position 0x%x in %s%05u.dat\n", new_size, m_prefix, pos.nFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative you could consider would be to use the trace
log level, so this would be logged only if the trace
loglevel is set with -loglevel, either globally or for this category.
LogPrint(BCLog::BLOCKSTORE, "Pre-allocating up to position 0x%x in %s%05u.dat\n", new_size, m_prefix, pos.nFile); | |
LogPrintLevel(BCLog::VALIDATION, BCLog::Level::Trace, "Pre-allocating up to position 0x%x in %s%05u.dat\n", new_size, m_prefix, pos.nFile); |
$ ./src/bitcoind -help-debug | grep -A10 loglevel
-loglevel=<level>|<category>:<level>
Set the global or per-category severity level for logging categories
enabled with the -debug configuration option or the logging RPC:
info, debug, trace (default=debug); warning and error levels are
always logged. If <category>:<level> is supplied, the setting
will override the global one and may be specified multiple times
to set multiple category-specific levels. <category> can be:
addrman, bench, blockstorage, cmpctblock, coindb, estimatefee,
http, i2p, ipc, leveldb, libevent, lock, mempool, mempoolrej,
net, proxy, prune, qt, rand, reindex, rpc, scan, selectcoins,
tor, txreconciliation, util, validation, walletdb, zmq.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Just changing the category might only shift verbose logging from one place to another. The idea of the log levels is to allow more granular control over detail).
from src/logging.h
enum class Level {
Trace = 0, // High-volume or detailed logging for development/debugging
Debug, // Reasonably noisy logging, but still usable in production
Info, // Default
Warning,
Error,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think blockstorage is correct place for this in any case. E.g. it also logs Leaving block file
. I don't know if it makes sense to reduce the log level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The info level is logged by default if -debug=on
for the category (as well as the debug level, for now during the transition period) and it would ease the review burden to use the new macros instead of the ones that will have to be updated. You may be right about BLOCKSTORE being a better place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(added a note to the PR description)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into switching to the LogPrintLevel
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d562077
to
7417743
Compare
CI network error https://cirrus-ci.com/task/4864754720702464?logs=ci#L61:
|
Note: The failed connections seems to be to the launchpad.net PPA with a newer bpfcc. Not using this newer PPA to install an up-to-date |
Approach ACK |
7417743
to
55792a5
Compare
55792a5
to
81269d6
Compare
src/flatfile.cpp
Outdated
@@ -66,7 +66,7 @@ size_t FlatFileSeq::Allocate(const FlatFilePos& pos, size_t add_size, bool& out_ | |||
if (CheckDiskSpace(m_dir, inc_size)) { | |||
FILE *file = Open(pos); | |||
if (file) { | |||
LogPrint(BCLog::VALIDATION, "Pre-allocating up to position 0x%x in %s%05u.dat\n", new_size, m_prefix, pos.nFile); | |||
LogPrintLevel(BCLog::BLOCKSTORAGE, BCLog::Level::Info, "Pre-allocating up to position 0x%x in %s%05u.dat\n", new_size, m_prefix, pos.nFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this upgraded from Level::Debug
to Level::Info
? That makes this logging unconditional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more complicated. WillLogCategoryLevel
logs >= BCLog::Level::Warning
for any category. For Info
it first checks if the category is selected, which is only the case if the user set -debug=blockstorage
.
Only if the category is set, it looks at category-specific log levels (-loglevel
), and defaults to DEFAULT_LOG_LEVEL
, which is currently Debug
(but I vaguely recall the idea was the raise that to Info
).
So this should not cause logging by default. I could still set the level to Debug
but perhaps that's better reserver for even lower level block storage stuff, if we ever add that. And indeed it didn't when I briefly tested it .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have Trace
available for "even lower level" stuff (currently used by the wallet for sql logging). The only Info
logging we currently do with a category is for libevent EVENT_LOG_MSG
, which I don't think is even used in the parts of libevent we actually use. I don't think this change makes sense, but that's probably mostly thinking that the logging api we have at the moment is confusing... (cf #28318)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to Debug
81269d6
to
f6429cc
Compare
I'm seeing 6 validation logs via validationinterface.cpp: There's also "Saw new header", "Saw new cmpctblock header" and "UpdateTip", but those aren't |
src/validationinterface.cpp
Outdated
#define LOG_EVENT(fmt, ...) \ | ||
LogPrint(BCLog::VALIDATION, fmt "\n", __VA_ARGS__) | ||
#define LOG_EVENT(category, level, fmt, ...) \ | ||
LogPrintLevel(category, level, fmt "\n", __VA_ARGS__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's not really any need for a separate LOG_EVENT
macro anymore -- all it saves now is adding a newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got rid of it.
src/validationinterface.cpp
Outdated
@@ -198,7 +197,7 @@ void CMainSignals::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockInd | |||
auto event = [pindexNew, pindexFork, fInitialDownload, this] { | |||
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.UpdatedBlockTip(pindexNew, pindexFork, fInitialDownload); }); | |||
}; | |||
ENQUEUE_AND_LOG_EVENT(event, "%s: new block hash=%s fork block hash=%s (in IBD=%s)", __func__, | |||
ENQUEUE_AND_LOG_EVENT(BCLog::VALIDATION, BCLog::Level::Info, event, "new block hash=%s fork block hash=%s (in IBD=%s)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also seems pointless to upgrade these to Info
... If anything, these seem more appropriate to downgrade to Trace
logging (the "Enqueuing" particularly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll switch these to Debug
and downgrade the Enqueuing
wrapper to trace.
src/validationinterface.cpp
Outdated
LOG_EVENT(fmt, local_name, __VA_ARGS__); \ | ||
event(); \ | ||
}); \ | ||
#define ENQUEUE_AND_LOG_EVENT(category, level, event, fmt, ...) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No real need to include the level
as a param, I think. Hardcoding it would make things a bit less noisy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR always sets level
to Debug
, so we don't need it here. But then any later tweak in log levels would have to edit this macro again.
330269f
to
3d40916
Compare
Dropping the function name (by default) made some of these messages ambiguous so I clarified them a bit in the second commit. |
3d40916
to
a0f6b39
Compare
@@ -246,17 +242,17 @@ void CMainSignals::ChainStateFlushed(const CBlockLocator &locator) { | |||
auto event = [locator, this] { | |||
m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.ChainStateFlushed(locator); }); | |||
}; | |||
ENQUEUE_AND_LOG_EVENT(event, "%s: block hash=%s", __func__, | |||
ENQUEUE_AND_LOG_EVENT(BCLog::VALIDATION, BCLog::Level::Debug, event, "chainstate flushed block hash=%s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an aside, this gets called 5-10 times for some blocks, zero times for most blocks.
Rebased after #28368. |
a0f6b39
to
6f14178
Compare
6f14178
to
f42c98e
Compare
Rebased and switched |
The Enqueuing wrapper uses level Trace.
Use -logsourcelocations instead.
This limits -debug=validation to messages related to blocks and headers.
f42c98e
to
17568b1
Compare
src/validationinterface.cpp
Outdated
#define ENQUEUE_AND_LOG_EVENT(category, level, event, fmt, name, ...) \ | ||
do { \ | ||
auto local_name = (name); \ | ||
LogTrace(category, "Enqueuing " fmt "\n", local_name, __VA_ARGS__); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e67ccf0: How is this a refactor? You are changing the behavior from debug to trace, no?
Also, I am not sure about this change. This makes intermittent test failures harder to debug, since trace is disabled. Also, below Debug is still used, so this drops only one of two log lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed this should be LogDebug()
in order to not change behavior.
The downgrade to trace should be in a different commit. Will look into this again.
This makes intermittent test failures harder to debug, since trace is disabled.
I'll look into what level to use. Lots of things have changed over the past few rebases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the trace level was always disabled, unless explicitly enabled? But I haven't double checked this.
🐙 This pull request conflicts with the target branch and needs rebase. |
There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
When running with
-debug=validation
the log is filled with:These log entries are more appropriate for
-debug=mempool
.This change limits
-debug=validation
to messages that are related to blocks and headers. It also downgradesEnqueuing
messages to theTrace
level.It makes it easier to run for a long time without excessive log file growth. This debug category is particularly useful for keeping track of problematic headers that were seen, the timing of reorgs, see also #27276.
Since this PR touches
validationinterface.cpp
anyway, it also includes a commit to drop function names from log messages, since we now have-logsourcelocations
.Similarly, though less important, I moved
[validation] Pre-allocating up to position 0x… in rev….dat
messages to blockstorage. This reduces the number of[validation]
log messages further.to 3 per (normal) block.The volume of log messages could also have been reduced by changing the log level of these messages to
trace
. Doing so would prevent a whack-a-mole game of moving log messages to different categories. However in this case I think the change in log category would be justified even if it didn't have a big impact on noise. I.e. someone running with-debug=mempool
would expect to see theTransactionAddedToMempool
messages and someone running with-debug=blockstorage
would perhaps be surprised to not see thePre-allocating
message.