[PR #934] [CLOSED] [TransferEngine] Conditionally enable SO_REUSEADDR in handshake daemon #1912

Closed
opened 2026-10-29 21:31:19 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/kvcache-ai/Mooncake/pull/934
Author: @staryxchen
Created: 10/16/2025
Status: ❌ Closed

Base: main ← Head: feat/add-socket-reuse-addr


📝 Commits (1)

  • 8803701 feat: enable SO_REUSEADDR option in need

📊 Changes

3 files changed (+23 additions, -4 deletions)

View changed files

📝 mooncake-transfer-engine/include/transfer_metadata_plugin.h (+2 -1)
📝 mooncake-transfer-engine/src/transfer_metadata.cpp (+8 -2)
📝 mooncake-transfer-engine/src/transfer_metadata_plugin.cpp (+13 -1)

📄 Description

Summary

Enable SO_REUSEADDR for the handshake listener when appropriate to reduce bind failures during rapid restarts or legacy port reuse.

Changes

  • API: HandShakePlugin::startDaemon now accepts a new parameter bool reuse_addr.
  • transfer_metadata.cpp:
    • In P2P handshake mode, call startDaemon(..., /*reuse_addr=*/true).
    • For non-P2P, derive reuse_addr from env MC_LEGACY_RPC_PORT_BINDING.
  • transfer_metadata_plugin.cpp:
    • If reuse_addr is true, set SO_REUSEADDR on the listener socket.

Motivation

Avoid "address already in use" errors on restarts or when legacy port binding semantics are needed, improving robustness of metadata handshake.

Behavior & Compatibility

  • Runtime behavior unchanged by default; SO_REUSEADDR is enabled only in P2P mode or when MC_LEGACY_RPC_PORT_BINDING is set.
  • Compile-time breaking change for custom HandShakePlugin implementations (signature updated). Implementations must add the reuse_addr parameter.

Notes

  • Env toggle: MC_LEGACY_RPC_PORT_BINDING to force reuse in non-P2P mode.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/kvcache-ai/Mooncake/pull/934 **Author:** [@staryxchen](https://github.com/staryxchen) **Created:** 10/16/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/add-socket-reuse-addr` --- ### 📝 Commits (1) - [`8803701`](https://github.com/kvcache-ai/Mooncake/commit/8803701187e5204361d1e911686c7c2d82121f7d) feat: enable SO_REUSEADDR option in need ### 📊 Changes **3 files changed** (+23 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `mooncake-transfer-engine/include/transfer_metadata_plugin.h` (+2 -1) 📝 `mooncake-transfer-engine/src/transfer_metadata.cpp` (+8 -2) 📝 `mooncake-transfer-engine/src/transfer_metadata_plugin.cpp` (+13 -1) </details> ### 📄 Description ## Summary Enable SO_REUSEADDR for the handshake listener when appropriate to reduce bind failures during rapid restarts or legacy port reuse. ## Changes - API: HandShakePlugin::startDaemon now accepts a new parameter `bool reuse_addr`. - transfer_metadata.cpp: - In P2P handshake mode, call `startDaemon(..., /*reuse_addr=*/true)`. - For non-P2P, derive `reuse_addr` from env `MC_LEGACY_RPC_PORT_BINDING`. - transfer_metadata_plugin.cpp: - If `reuse_addr` is true, set `SO_REUSEADDR` on the listener socket. ## Motivation Avoid "address already in use" errors on restarts or when legacy port binding semantics are needed, improving robustness of metadata handshake. ## Behavior & Compatibility - Runtime behavior unchanged by default; `SO_REUSEADDR` is enabled only in P2P mode or when `MC_LEGACY_RPC_PORT_BINDING` is set. - Compile-time breaking change for custom HandShakePlugin implementations (signature updated). Implementations must add the `reuse_addr` parameter. ## Notes - Env toggle: `MC_LEGACY_RPC_PORT_BINDING` to force reuse in non-P2P mode. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:31:19 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/Mooncake#1912
No description provided.