Repository navigation
test: Connection eviction logic tests - #16756
Conversation
27c04f4 to
b15b0b9
Compare
b15b0b9 to
7254563
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
c7f3adc to
42a01bf
Compare
|
TSan build timing out with last output being: |
|
Hmm, do you think this is caused by my changes? I didn't change the tests that timed out and the changes to |
|
Concept ACK, will review soon |
|
@mzumsande I'll let someone else weigh in on that, I just didn't want to blow away that result in case it was interesting. Restarted that build. |
|
@instagibbs Thanks! It happened again, so it does seem to be caused by the changes here. Will look into it and try to reproduce. |
|
Concept ACK Thanks for working on this! |
|
Found a few recent travis runs from merges where the TSan build timed out in the same way as here: |
|
Tested ACK 42a01bf1c15eeb625abdc8bbc0ef9a7852a2b1af |
|
Thanks for the review! |
42a01bf to
85e2300
Compare
|
Rebased and adjusted maxconnections after the merge of #15759 as explained above. |
|
The AppVeyor build failed - there seem to be intermittent failures with the new functional test. I can't reproduce so far, but will look into it. |
85e2300 to
2bbf130
Compare
|
I think that my assumption that the artificially slowed down peers never have the lowest minimum ping can be wrong, leading to the intermittent failure. I changed the functional test to use |
c72c4c0 to
92a73f8
Compare
|
I added those commits temporarily, because the AppVeyor build was failing and I couldn't reproduce this locally and wanted look at the debug.log, which AppVeyor currently doesnt' show due to #16894. I have removed the commits and fixed my mistake (not giving enough time for ping after adding a new peer). |
|
Thanks, I figured the timing of my review wasn't ideal. Looking forward to reviewing this. |
a0780c5 to
3758af7
Compare
|
@jonatack Thanks again - I took several of your suggestions (some slightly adapted) and pushed an update (just preferred not to split the asserts/logging from the rest) Yes, |
|
Tested ACK 3758af7 |
|
We'll cover this in review club on 2020-06-03: https://bitcoincore.reviews/16756.html |
rajarshimaitra
left a comment
There was a problem hiding this comment.
Concept ACK. Very nice test framework with elaborate comments to understand the logic. Below are few comments for mostly my own understanding and one probable minor bug.
There was a problem hiding this comment.
Is it possible to combine pings initialization with the actual filling of the list with minping data (happening few lines later) together? Any specific reason why they are separated by the add_p2p_connection?
There was a problem hiding this comment.
This is probably not material, but the reason is that I wanted to trigger the eviction mechanism immediately after the getpeerinfo call, so that the node does not get time to exchange additional pings with its peers while the test does other things.
There was a problem hiding this comment.
I wondered the same thing. It's confusing that you do some of the processing before adding the new peer (pings = [[...) and some after (for i in range(...). I think you should do all the processing before adding the new connection, since it'll take very little time, and the chance of there being another ping in between is ~zero.
If you do keep this ordering, I think it's worth a comment to say why you're doing it.
There was a problem hiding this comment.
I changed the ordering since the probability of furthers pings is extremely low.
There was a problem hiding this comment.
This is coming a little confusing for me, which 4 peers are protected via netgroup? If i understand correctly for functional testing all the peers are from same netgroup. So there's no way to differentiate between them via IP addresses. Is this what this comment is trying to convey?
There was a problem hiding this comment.
I believe these comments above try to convey this behaviour https://github.com/bitcoin/bitcoin/pull/16756/files#diff-96b7763a95e093580bd4507bce07ff22R10-R12
There was a problem hiding this comment.
I think it is impossible to say which peers are protected via netgroup because it can vary from run to run!
Since A) this is the first check in AttemptToEvictConnection() B) all test nodes have identical netgroup and C) std::sort does not guarantee to preserve the order of identical elements, this step should protect 4 arbitrary peers in the test.
If, for example, all 4 block-sending peers would be protected by chance, then the later EraseLastKElements with CompareNodeBlockTime would operate on identical elements and erase 4 random peers from vEvictionCandidates (protecting them).
The assertion at the end only tests that no peer assumed to be protected will be evicted. Its protection might happen in the EraseLastKElements specific to its unique feature, or earlier by chance.
There was a problem hiding this comment.
Yes, the only certainty we have regarding the evicted peers in this test is that it will be one of the zero-indexed peers in the set of {4, 5, 6, 7, 8} e.g. the slow-pinging ones.
fjahr
left a comment
There was a problem hiding this comment.
Code review ACK 3758af78564e9a0e059f38c11e941d68be192fb6
Nice test, thank you for adding it!
There was a problem hiding this comment.
Almost-ACK. Thanks for taking some of the suggestions in jonatack/bitcoin@c9e96a1.
|
Tested ACK 3758af78564e9a0e059f38c11e941d68be192fb6 |
3758af7 to
32c6ce0
Compare
|
Not specific to this PR, but related to the eviction logic code. Lines 932 to 935 in 657b82c The naMostConnections is storing the netgroup key with most number of connections. Why the variable name is like that? First i thought its a typo, but then it seems the a is simply added to distinguish it from nMostConnections, or is there a specific meaning to it? IMO feels like not so appropriate name to give to a variable which is not storing number of connections.
|
|
@rajarshimaitra feel free to open a PR on that if you have ideas on making the code more self-explanatory 👍 |
|
ACK 3758af78564e9a0e059f38c11e941d68be192fb6 thanks for adding useful test coverage. Reviewed/tested, re-checked the coherence with Thanks also for your patience and taking into consideration all the feedback. |
|
Building on John's style points, from The variables used as positional args in this test are sufficiently well-named that I didn't bring it up, but it's good to know. |
jnewbery
left a comment
There was a problem hiding this comment.
Looks great. A bunch of minor suggestions inline.
There was a problem hiding this comment.
I wondered the same thing. It's confusing that you do some of the processing before adding the new peer (pings = [[...) and some after (for i in range(...). I think you should do all the processing before adding the new connection, since it'll take very little time, and the chance of there being another ping in between is ~zero.
If you do keep this ordering, I think it's worth a comment to say why you're doing it.
32c6ce0 to
45eff75
Compare
|
I just pushed an update that should address all outstanding suggestions from review. |
|
Looking at it again, this test can be much simpler. One example: the ACK 45eff75 |
|
Tested ACK 45eff75 |
|
re-ACK 45eff75 Changes since my last reviews were minor improvements addressing nit review comments. |
| @@ -0,0 +1,129 @@ | |||
| #!/usr/bin/env python3 | |||
| # Copyright (c) 2019 The Bitcoin Core developers | |||
There was a problem hiding this comment.
nit
| # Copyright (c) 2019 The Bitcoin Core developers | |
| # Copyright (c) 2020 The Bitcoin Core developers |
|
re-ACK 45eff75 |
Summary: 45eff751c6d07007dabc365dc4c0e6c63e3fe5cf Add functional test for P2P eviction logic of inbound peers (Martin Zumsande) Pull request description: This adds a functional test for the eviction logic for inbound peers, which is triggered when the number of maximum connections is exceeded. The functional test covers eviction protection for peers that have sent us blocks or txns recently, or that have faster pings. I couldn't find a way to test the logic of `CConnman::AttemptToEvictConnection` that is based on netgroup (see #14210 for related discussion) Fixes #16660 (at least partially). [Edit: Earlier, this PR also contained a unit test, which was removed after the discussion] --- Backport of [[bitcoin/bitcoin#16756 | core#16756]] Test Plan: ninja all && ./test/test_runner.py p2p_eviction Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D9510
This adds a functional test for the eviction logic for inbound peers, which is triggered when the number of maximum connections is exceeded.
The functional test covers eviction protection for peers that have sent us blocks or txns recently, or that have faster pings. I couldn't find a way to test the logic of
CConnman::AttemptToEvictConnectionthat is based on netgroup (see #14210 for related discussion)Fixes #16660 (at least partially).
[Edit: Earlier, this PR also contained a unit test, which was removed after the discussion]