Avoid duplicate connection attempts to active nodes before handshake completion
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- java
- Ambito
- distributed-systems, networking
Direzione di ricerca
Start by tracing the active connection task and the existing 120-second address cache described in the issue, then inspect where connections close. Verify how active nodes are selected and how cache entries are removed. Done means repeated attempts are skipped during the handshake timeout while disconnected active nodes can reconnect after closure.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Rationale
Currently, the active connection task is executed every 3.6 seconds. During each execution, the task attempts to actively connect to all active nodes defined in the configuration file that have not yet successfully established a connection. The logic is illustrated as follows:
We have observed the following situation:
When the peer node experiences network latency or high system load, the P2P handshake process may be significantly delayed. As a result, multiple scheduled connection tasks may initiate several concurrent connection attempts to the same peer before the handshake completes. This causes the peer node to receive and process multiple handshake messages at nearly the same time, leading to unnecessary system resource consumption.
For example, node A initiates a connection to node B every 3.6 seconds, as shown in the following logs:
If node B is under heavy load and messages are queued, it might process multiple hello messages simultaneously at 17:05:56, as shown below:
Implementation
Add a handshake timeout mechanism for active nodes. If the handshake for a given node has not yet timed out, the system should not initiate a new connection request to the same node.
When initiating an active connection, the node address is cached for 120 seconds.
During the connection task, when selecting nodes (except those explicitly listed as active nodes), the system checks whether the node’s address already exists in the cache. If it does, it indicates that a connection attempt has already been made within the last 120 seconds, and the system will not initiate another one until the cache entry expires.
Proposed Optimization
Extend the same caching logic to active nodes:
Before initiating a connection to an active node, check whether its address exists in the cache. If it does, skip the connection attempt.
To ensure that disconnected active nodes can reconnect properly, remove their address from the cache when the connection is closed.
- Lingua principale
- Java
- Stelle
- 55
- Fork
- 38
- Merge medio
- 2g 1h
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di tronprotocol/libp2p
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 50/100
tronprotocol/libp2p#144 · 7 commenti ·
Tutte le issue di tronprotocol/libp2p
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
521xueweihan/HelloGitHub#4105 ·
-
Awaiting further input from submitter
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Regression in 5.9.0: CuratorCache fails with ClassCastException when the client is not a CuratorFrameworkBaseForse già presa @sftwnd l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno