Skip to content
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

chore: test peer connection management #3049

Merged
merged 6 commits into from
Sep 24, 2024

Conversation

Ivansete-status
Copy link
Collaborator

@Ivansete-status Ivansete-status commented Sep 23, 2024

Description

Enhance reconnect logic and fix reconnect tests.
The important point is that it is necessary to set a port different than zero in tests.

Changes

Issue

closes

@Ivansete-status Ivansete-status changed the title Test peer connection management chore: test peer connection management Sep 23, 2024
Copy link

github-actions bot commented Sep 23, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:3049

Built from 7b25036

Copy link
Contributor

@gabrielmer gabrielmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing! Thanks so much!

Added a small question :)

Comment on lines 625 to 626
reconnectDurationWithBackoffPeriod >
(reconnectDuration + backoffPeriod.seconds.float)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand why this is true. Shouldn't they be theoretically equal, but in practice any of them be longer than the other one?

Or in other words, why reconnectDuration + backoffPeriod.seconds.float can't be greater than reconnectDurationWithBackoffPeriod?

Copy link
Collaborator Author

@Ivansete-status Ivansete-status Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand why this is true. Shouldn't they be theoretically equal, but in practice any of them be longer than the other one?

Or in other words, why reconnectDuration + backoffPeriod.seconds.float can't be greater than reconnectDurationWithBackoffPeriod?

Actually, in both cases we are doing the same operation but, in when the backoff time assigned is != 0, then we add this extra block:

    if backoffTime > ZeroDuration:
      debug "Backing off before reconnect",
        peerId = peerInfo.peerId, backoffTime = backoffTime
      # We disconnected recently and still need to wait for a backoff period before connecting
      await sleepAsync(backoffTime)

... where we are adding an extra backoffTime plus the time spent in the debug call plus the if statement. Hence, the > condition should happen.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm I think that this can be problematic, the only difference is the if statement, the log and the time it takes to return from the sleep after the time has passed.

But for example, if the call to await pm.connectToNodes(@[peerInfo]) in the case without the backoff for some reason takes longer than in the run with the backoff, it can happen that the statement won't be true.

So given that it can be false in certain cases and that I don't think that the check adds much, I would personally remove it. But if not we can keep it and remove it if we see that it gives problems :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Morning! ah yes , makes sense. For now I just simplified the test in 772131e
Thanks!

@gabrielmer gabrielmer self-requested a review September 24, 2024 07:31
@Ivansete-status Ivansete-status merged commit 711e7db into master Sep 24, 2024
10 of 11 checks passed
@Ivansete-status Ivansete-status deleted the test-peer-connection-management branch September 24, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants