feat(resilience): broker /healthz + 优雅关闭 + pending 上限 + 重连 jitter (§8.2)#197
Open
raysonmeng wants to merge 1 commit into
Open
feat(resilience): broker /healthz + 优雅关闭 + pending 上限 + 重连 jitter (§8.2)#197raysonmeng wants to merge 1 commit into
raysonmeng wants to merge 1 commit into
Conversation
…11/§8.2) v3 §11.1 bullet 12 / §8.2 A 类韧性。无感重连(PR4)+ 落盘续投(PR6 store_if_offline + SQLite WAL)核心已就位,本 PR 补四个隔离的硬化点。 v3 §11.1 bullet 12 / §8.2 A-class resilience. Seamless reconnect (PR4) + durable replay (PR6 store_if_offline + SQLite WAL) are already in place; this PR hardens the four remaining isolated gaps. - broker /healthz:GET /healthz 返回最小非敏感 JSON(ok/pid/uptimeMs/connections), watchdog/supervisor 的存活探针。绑 Tailscale 100.x 任意 tailnet 节点可达,故 严禁含 token/PII/identity(测试断言不泄漏)。 - 优雅关闭(cli/broker.ts):SIGTERM/SIGINT → broker.stop() + store.close() (checkpoint WAL,保证 pending_deliveries 跨重启存活)+ exit 0。once 防重入。 - pending_deliveries 每-target 上限 MAX_PENDING_PER_TARGET=1000(drop-oldest, 两实现一致):永不重连的成员不会把表撑爆。 - 重连 jitter(broker-client.ts):scheduleReconnect 改用 reconnectDelay 的 equal-jitter(ceiling/2 + rand·ceiling/2,≤ maxMs),避免同时掉线的多 adapter 锁步重连打爆 broker(thundering herd)。 Tests: reconnect-delay (3, 纯函数 jitter 数学:floor/上限/不超 maxMs) + broker-healthz (2: 200+非敏感 body / connections 随连接增减) + broker-graceful-shutdown (1: spawn 真 CLI → SIGTERM → exit 0) + store 契约 pending 上限 (两实现各跑)。check 全绿 1803 pass。 Backlog(§8.2 推后,文档/注释标明):drain 即删=at-most-once(ACK delete-after-ack 推后)、WS 心跳(半开/漫游检测)、自建 watchdog 自动拉起(先用 systemd Restart=always)、 关机前 broker_shutdown 通知、无感重连后抑制重复 member_joined。 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要 / Summary
v3 §11.1 bullet 12 / §8.2 A 类韧性(stacked base =
feat/v3-pr9-lastmile/ #196)。无感重连(PR4)+ 落盘续投(PR6 store_if_offline + SQLite WAL)核心已就位,本 PR 补四个隔离的硬化点。改动
/healthz:返回最小非敏感 JSON{ok,pid,uptimeMs,connections},watchdog 探针。绑 Tailscale 100.x 任意节点可达 → 严禁含 token/PII(测试断言不泄漏)。测试 / Cross-review
reconnect-delay(3) + broker-healthz(2) + broker-graceful-shutdown(1, spawn 真 CLI→SIGTERM→exit0) + store-sqlite-durable(2, enqueue→close→重开→drain) + store 契约 pending 上限。2 轮 4 reviewer 连续两轮 0 真实 issue。check 1803 pass。
🤖 Generated with Claude Code