-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Fix logging RPC and -debugexclude with 0/none values, add test coverage, improve docs #27231
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
Fix logging RPC and -debugexclude with 0/none values, add test coverage, improve docs #27231
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. |
Any idea when/how this was broken? |
|
The behavior was intended to be added in #11191. I downloaded and tested v23.1 and the behavior wasn't functional: passing In v24, f1379ae made I've added this information to the PR description. |
It's still not clear if this was broken from the time it was merged, or at some other later point. This also does not work with 22.x, and any earlier versions are EOL. If it's been broken forever (or at least is in all currently maintained releases), and no ones even noticed, we could take advantage of that, to remove some of the complexity here; do we definitely need multiple different ways of achieving the same logging toggling? |
a5f8a7a to
215400a
Compare
980837e to
1509228
Compare
1509228 to
76f4e13
Compare
|
Rebased.
Exploring this, it doesn't look like there would be much code simplification gained by dropping It seems the way forward from here is to detect
Both involve similar code size/complexity and the second option seems preferable. The updated code here is about the same length as before, modulo missing test coverage and improved documentation. In the last pushes I've updated the PR description and first commit message with this info and improved the code and tests. This should be ready for further review! |
ajtowns
left a comment
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.
ACK 05143b2b94cc1d62f27fc73212aa59f9d471f2b8
Per the RPC logging help: ``` In addition, the following are available as category names with special meanings: - "all", "1" : represent all logging categories. - "none", "0" : even if other logging categories are specified, ignore all of them. ``` The behavior and documentation were added in bitcoin#11191, but over time and extended refactoring, the behavior is not longer working in Bitcoin Core versions 22/23/24 (the last supported versions currently) -- passing `0` or `none` has no effect. As there was no test coverage, the regressions went uncaught. In v24, `none` became unrecognized. During the same time period, passing `1` and `all` has been operational and documented. We therefore need to detect none/0 values and add test coverage in any case, and either: - leave the functionality out, raise with an error message if none/0 are passed, and update the RPC help documentation, or - fix the behavior by returning early. Both solutions involve essentially the same code size and complexity. Given that all/1 has been operational, and that none/0 has been documented and appears to have been operational previously, it seems preferable for consistency to support none/0 in symmetry with all/1, and as ACKed, intended, and documented since bitcoin#11191. --- This commit therefore adds: - the missing logic to make the functionality work - a missing logging.h include header - the relevant info in the logging RPC help doc
for consistency between them and for consistency with the logging RPC that uses the same logic for both -include and -exclude. Co-authored-by: Anthony Towns <[email protected]> Co-authored-by: Matthew Zipkin <[email protected]>
Can be tested with: ./src/bitcoind -h | grep -A12 "\-debug=<\|debugexclude"
and convert some comments to logging.
These cases should never be hit and are not needed; the 0/none logging category logic is handled only by the callers of IsNoneCategory() at these times: 1) during bitcoind startup init 2) when the `logging` RPC is invoked
and make the logging example in the developer notes zsh-compatible (for instance, zsh is currently the default shell in macOS). The RPC logging help can be tested with: ./src/bitcoin-cli help logging
05143b2 to
94b059f
Compare
|
Updated for @ajtowns' feedback to make
|
|
reACK 94b059f |
pinheadmz
left a comment
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.
re-ACK 94b059f
confirmed with range diff 93b387fe70 to 94b059f
Changes since last review address AJ's comments, minimal diff
Built and tested again locally
Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
ACK 94b059ffe403a948957152b96f24fba4d9ee31f0
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmT4nZIACgkQ5+KYS2KJ
yTpNDQ//Qlf3FswTPrPl8KG9iZAZvzA0CVvIeBRdFZWgtDJ1cGnIllxEsnVfE7R9
J6EXUEdZ+XCvzfVxLaLR9W23dWtRttNjC+cx/i7GexIYlAQfI4FGECuMitXXEYsR
pYujKEQ/6SETiI8TBJC3OqiWhBodDzzfzdevhiKKbX2dKY9c22OqTSP9TI6XJQfw
R8iqZuj4Tps4jUrNYoWQmo8C71KReVnCdDi3jeKKKXeGFfkb/hJNDqRRqtyLvqd2
Ih/N67BbjtHjtJ2U16x2qFN5xyyBer/nXRirM9GKTKrt6ZpDhY6k2k3h5pVOfKGg
JCUyKLh7N1sWplUbHVQQ+1SHSM9deuwHu/Ld9iuRcBydz4EM9J4oxskVE68CZclT
zynxdsAxoWvxuADMsKj94WY2zsJTr/mnJaq+d6prXTYTkdpxCi9BSno5GxJrIfRX
H7gwqAVxsx8npJbsUmkawB8NBI9xeeYiam1jhipFsWLyovPEAw5APao3/kuVNu58
sMz9ui0dUohtfbPsZoUbimSNofSc5anELjAxT3ekQFImCxHaZSf6/LQ+muNG/qRg
aGrK4fNXsRQX39BIv4E0fYTMm8Ud+r6LuRDTs+z1OEOt+VKVcGs4amQ4jMdtZios
nPeS3TZzKwWVYsjQCZ2LQyICDPkAIFxIRHLWtubrh/WYPM+Leik=
=jmH2
-----END PGP SIGNATURE-----
pinheadmz's public key is on keybase
Has this comment being replied to anywhere already? It does seem like it would be pretty easy to remove this behaviour -- removing "none" would mean that anyone who specified it would get an error on startup, which is a good clue to fix their config. And you get the same "actually, for this run I want to disable debugging stuff" by adding |
Yes, #27231 (comment) and the pull description contains that discussion as well. |
Why would you keep the |
|
I think that question is addressed in the pull description. |
I would have thought it was obvious that I don't see an answer to that question in the pull description, so that's an impressively unconstructive response. In the PR description, you claim:
But that's trivially not true: removing the code obviously results in a lower code size, and it also reduces the number of special cases that have to be documented and understood by users. No longer convinced this makes sense. |
It's reasonable to think one could gloss over the long-ish discussion in the OP (or what I attempted to communicate with it), as I think it replies to the question (at least, as I understood it). Here's the relevant section:
No, not if we check for the values and raise with an error message if the values are passed, with relevant test coverage. This ought to be done given that the functionality has been documented in the RPC help for around 7 years now, and perhaps also as it's not clear at what point it broke. That is what I meant by This pull improves a lot of things here. It not only fixes broken functionality while using lesser or equal lines of code (apart from test coverage and added docs), it also adds test coverage that has been missing for a long time and improves the documentation. It would be nice to see this finally move forward, and I appreciate your reviews of it! |
We already check for invalid categories and issue an error message for those. Doing the same thing for none/0 doesn't require extra code or extra test coverage.
FWIW, it broke in #12954 ("This is purely a refactor with no behavior changes." 🙄) -- previously #11191 was merged 2017-11-30 and #12954 was merged 2018-05-01 so this behaviour only worked for five months if you were running master, and only for the 0.16.x release. 0.16.0 was also the first release that considered (I have an alias
Why? The people who ACKed an old PR aren't gods, and we don't have to take their opinions at the time as gospel. As far as I can see, the other ways we (now) have of getting this behaviour are strictly superior. The reasons to have that behaviour originally was that "-debug" was originally a bool flag that got upgraded to support multiple distinct categories, and the arg parser at the time wasn't as clever/complicated as it is today. The reason given in 11191 for doing anything was
These commits have a bunch of extra complexity compared to dropping support for this behaviour:
Other commits seem mostly fine with 0/none special casing dropped:
|
|
I'm going to open an alternate pull that does what you suggest and see what reviewers (if any) prefer. |
|
🐙 This pull request conflicts with the target branch and needs rebase. |
Did this end up getting opened? Moving this PR to draft for now in any case. |
|
Will re-open as a new PR, along with the alternative version, as it is a good and mature patch with many updates made for reviews and nits. |
The logging RPC does not work as intended and as documented in its help when
0ornoneare passed.Per the RPC logging help:
The behavior and documentation were added in #11191, but over time and extended refactoring, the behavior no longer works in master and versions 22/23/24 (the last supported versions currently) -- passing
0/nonehas no effect. As there was no test coverage, the regressions went uncaught. In v24,nonebecame unrecognized:During the same time period, passing
1andallhas been operational and documented.Solution: detect
none/0values and add test coverage in any case, and either:leave the functionality out, raise with an error message if the values are passed, and update the RPC help documentation, or
fix the behavior by returning early.
Both solutions involve essentially the same code size and complexity. Given that
all/1has been operational, and thatnone/0has been documented and appears per the code of the original PR to have been operational, it seems preferable for consistency to supportnone/0in symmetry withall/1and as ACKed, intended, and documented in #11191.Done by this pull:
-debugand-debugexcludeconfig options to use the same code for consistency in behavior between them, and for consistency with the logging RPC that provides the same behavior for both-includeand-exclude./src/bitcoind -h | grep -A12 "\-debug=<\|debugexclude" && ./src/bitcoin-cli help loggingIf it is decided to backport a fix, commit
Fix RPC logging behavior when "0" and "none" values are passedcould probably suffice.