Skip to content

feat: implement source IP affinity for cluster workers - #4

Merged
rockyshi1993 merged 4 commits into
mainfrom
codex/ip-sticky-source-ip
Oct 10, 2026
Merged

rockyshi1993 merged 4 commits into
mainfrom
codex/ip-sticky-source-ip

Conversation

@rockyshi1993

@rockyshi1993 rockyshi1993 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Implement actual TCP source-IP affinity for cluster.sticky: "ip", replacing the previous round-robin placeholder. Master selects stable Worker slots with rendezvous hashing and hands paused sockets over a bounded offer/prepare/commit protocol. All five built-in adapters and their official factories use the shared Node HTTP receiver; Fastify uses its public serverFactory. The default remains sticky: "none".

Workers entering local application shutdown withdraw new-connection eligibility before closing resources, while in-flight connections keep the existing shutdown budget. Local exits retain automatic recovery in the same slot; Master-initiated draining does not create duplicate replacements. Readiness is rechecked immediately before slot activation, and forceClose errors are recorded without skipping subsequent cleanup. Chinese guidance and English guidance describe the matching behavior and IPC contract.

Validation:

  • Final Node 20 and Node 22 regressions: 307 tests passed on each runtime, including real socket handoff across all five adapters, rolling replacement, local shutdown, recovery policy, generation checks and late readiness.
  • The partial-header shutdown test verifies actual Worker forceClose and normal Worker exits before Master fallback. A separate SIGSTOP case verifies Master SIGKILL protection. Portable local-shutdown regressions run on Windows; Unix signal and source-IP fault cases use explicit platform skips.
  • Framework ESM/CJS builds, type checks, lint, formatting, the 1,216-entry public-surface check and documentation source/IPC contracts passed.
  • Full remote validation for 818baeb148e0f87efbfeb4b94c2c2f30930f9601: CI run 38003622430, passed all 16 jobs. The full coverage run passed 4,469 tests (2 conditional skips) across 228 files with the existing thresholds. Windows passed 158 tests with 5 platform skips, including the new local-shutdown and Worker force-close regressions.

No package version or tag changes are included.

@rockyshi1993
rockyshi1993 marked this pull request as ready for review October 10, 2026 02:35
@rockyshi1993
rockyshi1993 merged commit 9379a13 into main Oct 10, 2026
16 checks passed
@rockyshi1993
rockyshi1993 deleted the codex/ip-sticky-source-ip branch October 10, 2026 02:50
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.

1 participant