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

EVM-525 Write load test for adding peers #1537

Merged

Conversation

igorcrevar
Copy link
Contributor

@igorcrevar igorcrevar commented May 23, 2023

Description

Extend TestPeerAdditionDeletion with testing AddPeers when the peer number is significantly big. This test should address TODO comment in the test.

There was a deadlock because discovery was subscribed to network server events using s.SubscribeFn(context.Background(), discoveryService.HandleNetworkEvent).
In server_discovery.go, there was a definition of a custom callback function:

routingTable.PeerAdded = func(p peer.ID) {
    info := s.host.Peerstore().PeerInfo(p)
    s.addToDialQueue(&info, common.PriorityRandomDial)
}

and that callback function was called by the routing table library on the line _, err := d.routingTable.TryAddPeer(peerID, false, false) inside HandleNetworkEvent handler.

The method addToDialQueue is defined as:

 func (s *Server) addToDialQueue(addr *peer.AddrInfo, priority common.DialPriority) {
	s.dialQueue.AddTask(addr, priority)
	s.emitEvent(addr.ID, peerEvent.PeerAddedToDialQueue)
}

Emitting an event is a blocking function, new event is being emitted from the routine which handles event and each subscription channel used in the network server is not buffered. All these factors can lead to a deadlock.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

@igorcrevar igorcrevar added the bug fix Functionality that fixes a bug label May 23, 2023
@igorcrevar igorcrevar self-assigned this May 23, 2023
@igorcrevar igorcrevar force-pushed the feature/EVM-525-Write-load-test-for-adding-peers branch 2 times, most recently from e361b5d to ad42bbe Compare May 23, 2023 12:25
@igorcrevar igorcrevar force-pushed the feature/EVM-525-Write-load-test-for-adding-peers branch from ad42bbe to 64d5512 Compare May 23, 2023 12:26
@igorcrevar igorcrevar merged commit 96d0d89 into develop May 24, 2023
9 checks passed
@igorcrevar igorcrevar deleted the feature/EVM-525-Write-load-test-for-adding-peers branch May 24, 2023 08:36
@github-actions github-actions bot locked and limited conversation to collaborators May 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fix Functionality that fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants