Skip to content

fix: reuse master RPC pool during non-HA reconnects - #80

Merged
lihenga merged 2 commits into
v0.3.13.post1_l4from
lihenga/fix-non-ha-reconnect-pool-retention
Oct 21, 2026
Merged

lihenga merged 2 commits into
v0.3.13.post1_l4from
lihenga/fix-non-ha-reconnect-pool-retention

Conversation

@lihenga

@lihenga lihenga commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

2026-10-21:补充真实网络 DROP 验证

针对 review,新增一个受显式环境开关保护的 native 回归:连接建立并挂载内存段后,仅丢弃发往 Master RPC 端口的 TCP 包。故障持续 12 秒,RPC 请求超时设为 1 秒,解除后检查心跳、内存段及实际 RPC pool 身份。

测试只允许在与 PID 1 不同的网络命名空间内运行;普通 CI 会跳过。DROP 规则及超时环境变量会清理恢复。本次使用 unshare -n 创建独立网络命名空间,未更改容器已有网络或业务服务。

本轮验证与结论

指定环境:10.211.10.10 / Docker sglang0518_0920_yb,PR 原 head b7c8c6d7 的独立构建,加上本次测试;目录 /stortest/zhy_spcae/fixbug/pr80-half-open-20261021。

  • VERIFIED:三个原有 non-HA reconnect 回归通过。
  • VERIFIED:新增 DROP 用例通过;规则记录 25 个丢弃包,客户端经历 5 次心跳失败/重连尝试,Master 清理超时内存段后,解除 DROP 即恢复心跳和段可见性,整个过程 pool 指针不变。日志显示解除后约一个心跳周期恢复;用例允许最多 15 秒。
  • 初次故障注入未开始:隔离工具缺少 libip6tc.so.2。补齐任务目录内解包依赖后重跑新增用例;未安装系统包,未把该次环境失败算成行为验证。
  • VERIFIED:新增目标编译、一次有界自审、git diff --check 通过。
  • BLOCKED:clang-format/pre-commit 不可用。
  • UNTESTED:未新增 RDMA/多机网络故障验证。本轮黑洞验证使用 TCP 与 1 秒显式请求超时;没有将其描述为覆盖所有超时配置。

结果不支持额外引入强制重建 pool 的回退逻辑,因此本轮只增加测试,生产修复保持原样。

复现:在独立 network namespace 中启用 loopback,设置 MOONCAKE_TEST_IPTABLES 为可用的 iptables-legacy 可执行文件路径,然后运行:

non_ha_reconnect_test --gtest_filter='*Blackhole'

完整驱动与日志保存于上述目录;blackhole-test.log 为最终成功记录。下方保留此前修复及历史验证。


Description

Non-HA storage heartbeats previously forced a new master RPC pool on every reconnect attempt. Replaced pools are retained for coroutine lifetime safety, causing unbounded pool retention during master outages. Heartbeat reconnects now reuse the existing pool, which replaces closed connections itself.

The behavior change is confined to the heartbeat reconnect call. First-connect, address-change, explicit force-recreation and pool lifetime behavior remain as before. The regression checks the actual Client pool identity across a six-second master outage and same-address restart/remount.

Module

  • Mooncake Store (mooncake-store)

Type of Change

  • Bug fix

How Has This Been Tested?

Environment: opendas-prometheus, container sglang0518_0920_yb, existing Release CMake build. Joint integration 9bdd6d96720ed7e8a7e10b8deb9918ed03494957.

cmake --build build -j 8 --target non_ha_reconnect_test dfs_immutable_bucket_client_test
build/mooncake-store/tests/non_ha_reconnect_test
build/mooncake-store/tests/dfs_immutable_bucket_client_test
  • VERIFIED: non_ha_reconnect_test: 3/3 passed, including stable actual heartbeat pool identity while master is down and after automatic reconnect/remount.
  • VERIFIED: dfs_immutable_bucket_client_test: 22 passed, 2 checksum-disabled skips. Includes new Client creation after same-address master restart and backfill failure/recovery.
  • VERIFIED: unchanged rpc_client_io_context_test: 3/3 passed in the joint build.
  • Joint master service suite and baseline failure details are recorded in PR fix: recover DFS initialization failures and backfill degraded writes #79; they are not claimed green here.

Full logs/XML: /stortest/zhy_spcae/fixbug/dfs-recovery-pool-20261020/.

Checklist

  • I have performed an AI self-review of the scoped changes
  • I have added regression assertions for the changed behavior
  • git diff --check passes
  • I have formatted my code using ./scripts/code_format.sh (clang-format unavailable)
  • I have run pre-commit on the files changed (tool unavailable)
  • Human review of all changed lines

AI Assistance Disclosure

  • AI tools were used: Codex implemented the fix and regression assertions, and ran validation. Human review remains pending.

Commit consolidation (2026-10-20)

This PR now contains one commit: b7c8c6d7f9075cdb8ce5bedba9987e6af734f484. Its complete Git tree is identical to the previous PR head. Both squashed PRs were cherry-picked onto L4 baseline 18c9e4a3 into lihenga/integrate-dfs-bugfixes-20261020 at 60ae912dedb3d627ccd1b7485a1508b01fa6241f; that integration tree is identical to the previously tested 9bdd6d96. No unit tests were rerun for this history-only change; the test results and limitations above remain the validation evidence.

@github-actions github-actions Bot added the store label Oct 20, 2026
@lihenga
lihenga force-pushed the lihenga/fix-non-ha-reconnect-pool-retention branch from 98867be to b7c8c6d Compare October 20, 2026 05:44
@lzb16

lzb16 commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

审核与实测意见

我们审核了 #80(b7c8c6d7),并在整合了本 PR 的构建上与不含本 PR 的 18c9e4a3 并行实测。行号按 b7c8c6d7。

结论:实测有效。非 HA 模式下 master 不可用期间,每次重连不再泄漏内存,建议合入。另有一个场景建议补测(第 2 条)。

1. 实测

方法:master 正常运行后 SIGKILL,停 300 s,client 约每秒重连一次,共 300 次;之后在同一地址重启 master。每 10 s 采样一次 client 的匿名内存、线程数和 fd 数。

不含本 PR(18c9e4a3) 含本 PR
master 停止后的一次性增加 约 1 MiB,线程 +15,fd +40 约 1.5 MiB(前 38 次重连内),线程 +15,fd +40
之后每次重连 每 30–40 次涨 264 KiB,约 8 KiB/次,线性增长 第 38 次到第 300 次匿名内存不变(<1 KiB/次)
300 次重连后的总增长 3.4 MiB 1.6 MiB,全部是前 38 次的一次性增加

两个版本在 master 恢复后都重连成功,线程数和 fd 数在一次性增加后都不再变化。

2. 建议补测:半开连接

  • 本 PR 改为复用原连接池(client_service.cpp:5510),注释说关闭的连接由连接池自己替换。我们的测试和 PR 里的 non_ha_reconnect_test,都是 master 进程退出、内核关闭连接的场景。
  • 当初加 force_recreate 是为了修“重连卡住”。如果 master 所在主机宕机或遇到网络黑洞(对端不回 RST),池里的连接看起来仍然存在。复用这样的连接池后,master 恢复时能否及时重连,需要验证。
  • 建议:用防火墙丢弃(DROP,不是 REJECT)发往 master 端口的包,持续一段时间后再放开,看 client 能否在 master 可达后的若干个心跳周期内恢复。如果不能,可以在连续多次 ping 超时后再强制重建一次连接池,按指数退避限制频率,就不会再出现每秒一次的泄漏。

@lihenga
lihenga merged commit 50ef8e2 into v0.3.13.post1_l4 Oct 21, 2026
1 check passed
@Yong-ee Yong-ee mentioned this pull request Oct 21, 2026
5 of 16 tasks
@lihenga
lihenga deleted the lihenga/fix-non-ha-reconnect-pool-retention branch November 4, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants