Provide logging and info to help people
- use the
DEBUG_ADDRMANconsistency checks - verify the checks are running
- see when and how often they are being performed
Provide logging and info to help people
DEBUG_ADDRMAN consistency checks<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, 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.
Concept ACK
I see how this can be useful and is a nice addition. After following your instructions, my debug file is filled with thousands of lines of:
2021-07-19T04:37:25Z Check addrman
2021-07-19T04:37:25Z ADDRMAN CONSISTENCY CHECK FAILED!!! err=-19
Wonder what other useful information could be logged.
282 | @@ -282,6 +283,20 @@ configure option adds `-DDEBUG_LOCKORDER` to the compiler flags. This inserts 283 | run-time checks to keep track of which locks are held and adds warnings to the 284 | `debug.log` file if inconsistencies are detected. 285 | 286 | +### DEBUG_ADDRMAN 287 | + 288 | +Defining `DEBUG_ADDRMAN` performs frequent (and expensive) consistency checks on 289 | +the entire addrman data structure. Add this line to enable it, e.g. in
is src/addrman.h the only file we could define this in? Are there other files we could do this in. If there are I feel as though we could improve the note here. Otherwise, we could remove e.g.
Good point. Improved as follows:
Defining `DEBUG_ADDRMAN` performs frequent (and expensive) consistency checks on
-the entire addrman data structure. Add this line to enable it, e.g. in
-`src/addrman.h`
+the entire addrman data structure. To enable it, add this line in `src/addrman.h`
+before `void Check()`
Concept ACK
291 | + 292 | +```cpp 293 | +#define DEBUG_ADDRMAN 294 | +``` 295 | + 296 | +and then build (`make`) and run bitcoind. You can use the `-debug=addrman`
then build (`make`) and run bitcoind. You can use the `-debug=addrman`
cr ACK 68ebaa03f42732e70ab6922def36b3eaaeee8b50
Making this more clear makes sense since one might incorrectly assume that --enable-debug would define DEBUG_ADDRMAN.
ACK 68ebaa03f42732e70ab6922def36b3eaaeee8b50
I remember enabling DEBUG_ADDRMAN once as described, but asking myself if I was really supposed to do it this way.
282 | @@ -282,6 +283,20 @@ configure option adds `-DDEBUG_LOCKORDER` to the compiler flags. This inserts 283 | run-time checks to keep track of which locks are held and adds warnings to the 284 | `debug.log` file if inconsistencies are detected. 285 | 286 | +### DEBUG_ADDRMAN 287 | + 288 | +Defining `DEBUG_ADDRMAN` performs frequent (and expensive) consistency checks on 289 | +the entire addrman data structure. To enable it, add this line in `src/addrman.h`
You can also just add -DDEBUG_ADDRMAN to your CPPFLAGS, rather than modifying the source.
Thanks, added.
ACK baac29c74e475a1e7239355e710f2c6ad0cd19e0
ACK baac29c74e475a1e7239355e710f2c6ad0cd19e0
ACK baac29c74e475a1e7239355e710f2c6ad0cd19e0
Tested on signet. #20233 seems to be a very promising long-term alternative by allowing activating addrman consistency checks at runtime. Right now, the documentation introduced in this PR will serve as a good and useful guide in how to properly use the compile-time debug option 👍. Logging the consistency checks also makes a lot of sense.
Oh, I didn't see the two changes as mutually exclusive. I think the logging is still pertinent and was planning to rebase and drop the doc commit if that PR is merged, and perhaps add some follow-ups.
Hm, seems I don't have the privileges required to re-open my PR for the logging. Will open a new one, I guess.