Skip to content

fix(ws): 身份竞态守卫测试改确定性重叠,消除负载型 CI flake - #2200

Merged
DeliciousBuding merged 1 commit into
masterfrom
fix/ws-identity-race-test-flake
Sep 1, 2026
Merged

fix(ws): 身份竞态守卫测试改确定性重叠,消除负载型 CI flake#2200
DeliciousBuding merged 1 commit into
masterfrom
fix/ws-identity-race-test-flake

Conversation

@DeliciousBuding

Copy link
Copy Markdown
Collaborator

问题

TestConn_AuthSnapshotIsRaceFreeAndCoherent#2194 引入的竞态守卫测试)在 Windows CI 失败:

conn_identity_race_test.go:63: reader never observed a bound identity; test exercised no overlap

根因不是产品竞态:测试的读者跑固定 20000 次 Auth(),写者 churn 直到 stop。它假设写者会在读者窗口内至少绑定一次身份——纯调度假设。高负载 runner(Windows CI、本机 4C 满载 make test)下写者可整窗饥饿,20000 次读全见空身份 → seen==0 误报失败。本机已复现(满负载挂、单跑 3/3 绿)。

修复(测试 only,零产品改动)

  • goroutine 启动前预绑一次身份(happens-before 于 goroutine 创建,无新竞态面)。
  • churn 循环 SetAuth 永不写空值 → 每次 Auth() 读必见已绑定三元组。
  • 重叠从「调度运气」变为「构造保证」;seen==0 改作纯 harness 守卫。
  • -race 覆盖不变:并发 churn + 读原样保留。

证据

  • go test -race -count=10:绿
  • GOMAXPROCS=1 -count=5(饥饿最劣况):绿
  • ws 包全量 + make test 全绿(MAKE_TEST_EXIT=0)

本 PR 是 #2198 / #2199 CI 变绿的前置(该 flake 当前阻塞所有含 hub 单测的 lane)。

- TestConn_AuthSnapshotIsRaceFreeAndCoherent 原依赖写者在读者固定
  迭代窗口内抢到 CPU;高负载 runner(Windows CI / 共享 4C 机)下写者
  可整窗饥饿 → 误报 'reader never observed a bound identity'。
- 修法:goroutine 启动前预绑一次身份(happens-before,无新竞态面),
  且 SetAuth 永不写空值 → 每次 Auth() 读必见已绑定三元组,重叠成为
  构造保证而非调度运气。-race 覆盖不变(并发 churn + 读仍在跑)。
- 证据:-race x10、GOMAXPROCS=1 x5(饥饿最劣况)、ws 全量、make test 全绿。

Co-authored-by: Cursor <cursor@vectorcontrol.tech>
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 6af3ed7a-6834-41d6-b8f2-613af1e37b41

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DeliciousBuding
DeliciousBuding merged commit f2cf27f into master Sep 1, 2026
39 checks passed
@DeliciousBuding
DeliciousBuding deleted the fix/ws-identity-race-test-flake branch September 1, 2026 22:47
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