Skip to content

Automatically disconnect and remove the peer from consul registry#89

Merged
anhthii merged 1 commit into
masterfrom
fix-node-disconnected-not-reflect
Aug 16, 2025
Merged

Automatically disconnect and remove the peer from consul registry#89
anhthii merged 1 commit into
masterfrom
fix-node-disconnected-not-reflect

Conversation

@anhthii
Copy link
Copy Markdown
Contributor

@anhthii anhthii commented Aug 16, 2025

Automatically disconnect and remove unresponsive peers from Consul registry

Description

This PR enhances peer health management in the MPC node registry to ensure disconnected or unresponsive peers are automatically removed from Consul.

Key Changes

registry

  • Added healthCheck using DirectMessaging to actively probe peers via NATS.
  • Implemented checkPeersHealth routine that periodically sends health check messages to all ready peers.
  • If a peer does not respond (detected by "no responders" error), its ready key is deleted from Consul.
  • Updated NewRegistry to accept directMessaging for health checks.

point2point

  • Added SendToOtherWithRetry method with configurable retry attempts, delays, and backoff for reliable health checks.
  • Improved Listen method to handle subscription flush errors and clean up on failure.

main.go

  • Updated NewRegistry initialization to pass in directMessaging.
  • Added NATS Drain() call during shutdown for clean disconnection.

keygen_consumer

  • Fixed log messages to correctly reference keygen events instead of signing events.

Impact

  • Ensures the registry always reflects the actual set of active peers.
  • Reduces stale peer entries in Consul, preventing potential coordination or signing errors.
  • Improves node reliability and self-healing in multi-peer setups.

Comment thread pkg/messaging/point2point.go Fixed
@anhthii anhthii force-pushed the fix-node-disconnected-not-reflect branch from b729611 to 16b00a4 Compare August 16, 2025 05:08
@anhthii anhthii force-pushed the fix-node-disconnected-not-reflect branch from 16b00a4 to 75062c0 Compare August 16, 2025 05:14
@anhthii anhthii merged commit d04f837 into master Aug 16, 2025
22 checks passed
@anhthii anhthii deleted the fix-node-disconnected-not-reflect branch August 16, 2025 05:16
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.

2 participants