Skip to content

Node fails to synchronize blocks after a peer is randomly disconnected #6504

Closed

Description

@jakamobiii

Software Versions

OS : Linux
JVM : Oracle Corporation 1.8.0_161 amd64
Version : 4.8.0

Expected behaviour

When the node has established multiple valid peer connections, it should be able to fetch block data from multiple available peers.
Even if a single peer is disconnected (including random disconnection), the node should automatically switch to other already connected peers to continue block synchronization, ensuring continuity and stability of the sync process.

Actual behaviour

During runtime, the following abnormal behavior was observed:

  • The node successfully establishes approximately 30 P2P connections.
  • However, during block synchronization, it appears that the node continuously requests blocks from only a single peer, while the other connections are not effectively utilized.
  • When this peer is disconnected by the random elimination strategy, the following log is printed:
19:22:47.166 INFO  [peerWorker-5] [net](PeerConnection.java:184) Send peer /IP:50816 message type: P2P_DISCONNECT
reason: RANDOM_ELIMINATION

After this connection is terminated, the node does not automatically resume block requests from other already connected peers. The block height stops updating, and the node enters a state where it can no longer continue block synchronization.

Based on logs and observed behavior:

  • There appears to be a strong single-peer dependency for block data syncing.
  • When the random elimination strategy is triggered, the only actively used peer is disconnected, which raises the question of whether there is an issue with the random elimination strategy.

Frequency

This issue is not consistently reproducible and was not clearly observed in earlier runs.

Activity

  1. zeusoo001 commented on Jan 7, 2026

    @zeusoo001
    Contributor

    The current random disconnection strategy is relatively simple, the logic for “random disconnection” is as follows:

    1. If the number of established peers is less than the configured maximum connections, return immediately.
    2. Filter out trusted nodes.
    3. If the number of peers in the broadcasting state ≥ 3, select one of the broadcasting peers using a “weighted random algorithm” and disconnect it.
    4. Otherwise, randomly eliminate one peer from the syncing peers:
      1. If needSyncFromPeerCount < 2, eliminate one peer from the needSyncFromUs nodes.
      2. Otherwise, randomly eliminate one peer from all syncing peers.

    Under this strategy, any node except trusted nodes has the potential to be disconnected. This is a good issue, and we can discuss how to optimize this strategy to minimize the disconnection of good connections.

  2. halibobo1205 commented on Jan 12, 2026

    @halibobo1205
    Collaborator

    @zeusoo001 What was the rationale behind the original design of RANDOM_ELIMINATION?

  3. zeusoo001 commented on Jan 12, 2026

    @zeusoo001
    Contributor

    @halibobo1205 The system introduced a “random disconnection” mechanism in its early design to automatically release resources when the maximum number of connections is reached. When the node’s connection pool is full, the system randomly selects an existing connection to disconnect, in order to maintain a certain level of connection churn within the pool. This strategy was originally intended to improve the overall connectivity and efficiency of the network.

  4. jakamobiii commented on Jan 15, 2026

    @jakamobiii
    Author

    @zeusoo001 Are there any good optimization solutions for the random disconnection strategy?

  5. zeusoo001 commented on Jan 15, 2026

    @zeusoo001
    Contributor

    @jakamobiii To avoid randomly disconnecting relatively good peers, a “last block received time” field can be added to the peer object. When applying the random disconnection strategy, the top N peers with the most recent “last block received time” are filtered out, and only the remaining peers participate in the random disconnection process.

  6. waynercheung commented on Jan 15, 2026

    @waynercheung
    Collaborator

    @zeusoo001
    As you mentioned that The node successfully establishes approximately 30 P2P connections., so what specific factors contribute to the node's single-peer dependency during block synchronization, and how can peer selection be improved for better load balancing?

  7. zeusoo001 commented on Jan 26, 2026

    @zeusoo001
    Contributor

    @waynercheung Other peers may have modified the code logic. To fix this issue, please refer to the description above; it can be achieved by optimizing the random disconnection strategy.

  8. zeusoo001 commented on Mar 24, 2026

    @zeusoo001
    Contributor

    This issue is included in the v4.8.2 release (ref: #6585). Development is currently in progress. We will continue to sync updates here as work advances. The fix is tentatively expected to be completed by May 2026.

  9. moved this to In Review in java-tronon Mar 31, 2026
  10. moved this from In Review to In Progress in java-tronon Mar 31, 2026
  11. moved this from In Progress to Done in java-tronon May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions