Skip to content

test(gate-hub): expose TLS status listener blocking - #170

Merged
TN019 merged 10 commits into
mainfrom
test/tls-status-head-of-line
Dec 1, 2026
Merged

TN019 merged 10 commits into
mainfrom
test/tls-status-head-of-line

Conversation

@TN019

@TN019 TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Why

A north-link black hole or a client that stops reading can delay every gate using the serial TLS status listener.

What changed

  • Add a four-gate path-MTU scenario with gate-side 8444 probes, separate staff-side checks and complete cleanup.
  • Add controlled slow-client and queue-overload cases, recording the current serial behavior explicitly in the test expectation.

How to verify

On Linux with the build dependencies listed in Dockerfile.build, run from the repository root:

cmake --preset debug
cmake --build --preset debug
ctest --preset debug -R '^(status_tls_workers)$' --output-on-failure

At this point CTest passes by matching the known blocking diagnostic, not by proving isolation. The output must report the /status wait behind one and behind three clients that stopped reading, a connection beyond the queue that was not closed within 1 s, and queue-full refusals that were not counted.

In the venue lab with all four gates running, sh lab/status-stall-blackhole.sh is expected to print the held-listener result and exit 1 until 8444 serves more than one connection at a time; exit 2 means an environment mismatch or a failed cleanup.


背景

北向链路黑洞或停止读取的客户端,会拖住使用串行 TLS 状态监听器的所有闸机。

改动

  • 加入四闸机场景,制造路径 MTU 故障,从闸机侧探测 8444,另查员工侧状态,并完整恢复环境。
  • 增加受控慢客户端与队列过载用例,在测试预期中明确记录当前串行行为。

怎么验证

在 Linux 环境安装 Dockerfile.build 列出的构建依赖后,从仓库根目录运行:

cmake --preset debug
cmake --build --preset debug
ctest --preset debug -R '^(status_tls_workers)$' --output-on-failure

此时 CTest 是匹配已知阻塞诊断才通过,并不证明已实现隔离。输出应列出:一个、三个客户端停止读取时 /status 各等了多久,队列之外的连接 1 秒内没有被关闭,以及队列满的拒绝没有计数。

在场馆实验环境中让四台闸机都运行,再执行 sh lab/status-stall-blackhole.sh。在 8444 能同时处理多条连接之前,它应报告端口被占住并以 1 退出;以 2 退出说明环境不符或收尾失败。

Ben Carter and others added 10 commits October 28, 2026 16:30
The hub recorded connections that had not identified themselves under
the name "unknown". Writing list status for every record made that
pseudo-gate look like a gate reporting no version.

Write list status only for gates that identified themselves and sent
a heartbeat. A CONFIG from an unidentified connection records nothing.
… the uplink watcher has stopped

Cut both data-centre exits, restore them, then kill the hub's uplink
watcher. Compare Mailpit message IDs across each separate fault.

Each case expects exactly one mail to manager@elsworne.example from
alerts@elsworne.example through the venue's own mail server, which
remains available without the data-centre link. The subjects are
"Data centre unreachable" and "Uplink watcher stopped". Allow 20 s:
5 s for the probe, 10 s for the alert threshold, 1 s for the alert
loop, and 4 s for mail submission; the watcher checks every second.

Today neither mail is sent, so both judgements fail. Exit 0 means both
pass, 1 means a judgement fails, and 2 means an environment or cleanup
failure.
…he uplink watcher stops

The hub logged data-centre failures, and the uplink watcher could exit
without notifying the venue.

Submit mail after the shared alert threshold, once per incident. Keep
sent incidents in the atomic state file across hub restarts, and re-arm
each alert when its condition recovers without sending recovery mail.

Have the watcher update a heartbeat file each loop. Its modification
time uses the clock shared with the hub, since a shell cannot portably
read a monotonic clock. Give restarted hubs a fresh threshold of grace.

Add a CI test for transient and repeated faults, recovery, mail headers,
restart persistence, and the watcher grace period.

Co-authored-by: Yuki Tanaka <yuki.tanaka@elsworne.example>
A signed barcode of about 159 characters does not fit the binary
list's 32-byte record. Publish a 20000-ticket signed text list at
/season.txt from both data-centre services at lab scale. Keep the
signing key in dc and dc2 only. Leave /tickets.gpb and the hub
unchanged. Test publication with the gates' signature verifier,
HTTP and TLS responses, caching, ranges, and tampering.
Move ticket marking out of add_entry. Startup journal loading still
marks each entry in order; after a new reports_record result, the hub
marks the ticket under store_lock before updating status and metrics
or replying.

The ticket store is read under store_lock during requests, and the
report lock is never held with it. Behaviour is unchanged: admission
was already thread-safe and the store does not change at run time
today. Document the lock order and startup journal marking.
The hub still rejects a signed ticket found only in the synced season list, although a successful sync should make that list available for decisions. After the start file changes in place, /tickets serves its new bytes while scans still use the loaded list; both should use the same snapshot. Growing or shrinking the file during a /tickets reply changes the bytes sent, and a short reply is counted as 200; the reply should contain the loaded list and be counted accurately.
The hub synced a list it never used for decisions, while /tickets reread the start file on every request. A header-time ETag could leave the hub on an old list behind repeated 304 replies.

The hub now syncs /season.txt, checks the installed body before conditional requests, and switches decisions and /tickets together using a reference-counted snapshot. It carries used admissions and recorded offline reports across a switch.

Here verified means the downloaded file SHA-256 matches the confirmed ETag, the whole list loads under the start-file rules, and the file and its directory have been synced.
After the hub fix, the hub takes its season list from the data centre and serves the verified in-memory list. Drills that rewrote the hub start file and restarted it now publish their extra tickets from the data centre. The drills wait for installation and restore the previous publication during cleanup.
…LS status port

With the season list at about 3.5 MB, a north gate whose download is lost in a path-MTU black hole keeps the hub's single TLS status listener busy for about six seconds once per 20-second fetch cycle. Venue gates that ask during that time give up after 300 ms. The drill fails until 8444 serves more than one connection at a time.
… every gate

Port 8444 serves one connection at a time, so a client that asks for /tickets and stops reading makes every other gate wait seconds for /status. A connection beyond the work queue should be closed at once and counted.
@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Ben Carter · reviewer

Does the green CTest result mean 8444 already serves clients concurrently?


CTest 通过是否说明 8444 已经并发服务客户端?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Noah Williams · author

No. This diagnostic snapshot explicitly matches the existing failure output. A later concurrency fix must remove that expectation and satisfy the ordinary assertions.


不是。这个诊断版本明确匹配现有故障输出;后续并发修复必须移除该预期,并满足正常断言。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Yuki Tanaka · reviewer

If the drill stops halfway, does the router keep MTU 1400 and lose the fragmentation-needed rule?


演练如果中途停下,路由器会不会一直停在 MTU 1400,还丢了“需要分片”那条规则?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Noah Williams · author

No. The exit trap puts the rule back at its original position, restores the MTU and compares the whole OUTPUT chain with the copy taken before the change. It also restores the extra ticket file, restarts the hub and waits for all four gates to reinstall the original list. Any cleanup failure exits 2 and keeps the backup directory.


不会。退出时的 trap 会把规则插回原来的位置,恢复 MTU,并把整条 OUTPUT 链和改动前保存的副本逐行比对;还会还原额外票文件、重启 hub,等四台闸机装回原票单。收尾任何一步失败都以 2 退出,并保留备份目录。

@TN019
TN019 merged commit 1785db2 into main Dec 1, 2026
6 of 10 checks passed
@TN019
TN019 deleted the test/tls-status-head-of-line branch December 1, 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