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

Simplify getting a hostinfo or starting a handshake with one #954

Merged
merged 2 commits into from
Aug 21, 2023

Conversation

nbrownus
Copy link
Collaborator

@nbrownus nbrownus commented Aug 9, 2023

This PR is based on #953. The base branch will be changed to master when it merges.

The goal here is to simplify getting a hostinfo and starting a handshake, paving the way to invert how handshake state is tracked so that we don't have to keep all of it around in a fully formed hostinfo.

This should also resolve the last remaining racy issues with interactions between the pending and main hostmap.

There are 2 trouble spots here.

  1. HandshakeManager.allocateIndex acquires a main hostmap read lock and a pending hostmap write lock while it holds a hostinfo lock. I haven't found anywhere where that order is violated yet but it's worth some extra eyes.
  2. The big lie correction in handshake_ix.go is inherently racy, I think it's a little better now than it was before but solving it entirely requires inverting the interactions with HandshakeManager.

wadey
wadey previously approved these changes Aug 15, 2023
Copy link
Member

@wadey wadey left a comment

Choose a reason for hiding this comment

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

I think overall this looks good. I do see some races that could still happen due to the transition from handshakeManager to main hostmap, but I dont think there is an easy way to solve them unless we only had one map that contained both pending and active.

inside.go Show resolved Hide resolved
Base automatically changed from no-cert-state to master August 21, 2023 19:11
@nbrownus nbrownus dismissed wadey’s stale review August 21, 2023 19:11

The base branch was changed.

@nbrownus nbrownus merged commit 076ebc6 into master Aug 21, 2023
6 checks passed
@nbrownus nbrownus deleted the getOrHandshake branch August 21, 2023 23:51
@wadey wadey added this to the v1.8.0 milestone Sep 22, 2023
wadey added a commit that referenced this pull request May 28, 2024
We had a rare deadlock in GetOrHandshake because we kept the hostmap
lock when we do the call to StartHandshake. StartHandshake can block
while sending to the lighthouse query worker channel, and that worker
needs to be able to grab the hostmap lock to do its work. Other calls
for StartHandshake don't hold the hostmap lock so we should be able to
drop it here.

This lock was originally added with: #954
wadey added a commit that referenced this pull request May 29, 2024
We had a rare deadlock in GetOrHandshake because we kept the hostmap
lock when we do the call to StartHandshake. StartHandshake can block
while sending to the lighthouse query worker channel, and that worker
needs to be able to grab the hostmap lock to do its work. Other calls
for StartHandshake don't hold the hostmap lock so we should be able to
drop it here.

This lock was originally added with: #954
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants