Skip to content

fix(gate-hub): isolate TLS status requests with bounded workers - #172

Merged
TN019 merged 9 commits into
mainfrom
fix/tls-status-worker-pool
Dec 1, 2026
Merged

TN019 merged 9 commits into
mainfrom
fix/tls-status-worker-pool

Conversation

@TN019

@TN019 TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Why

A single stalled TLS download blocks unrelated gates despite per-connection deadlines.

What changed

  • Serve 8444 with four workers and a queue of 16; close excess connections, count refusals and rate-limit queue-full logs.
  • Share bounded queue code with the gate port, keep 8081 on its staff thread, retain deadlines and replace diagnostic expectations with regression assertions.

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|status_deadline|hub_integration)$' --output-on-failure

Status requests must remain responsive with up to three occupied workers, excess queued connections must close promptly and refusal metrics must increase. Four occupied workers can still cause waiting.


背景

即使每条连接有期限,一次 TLS 下载停滞仍会阻塞其他闸机。

改动

  • 为 8444 配置四个 worker 和容量 16 的队列;超额连接关闭,记录拒绝计数并限制队列满日志频率。
  • 与闸机端口共用有界队列代码,8081 保留独立员工线程,保留期限,并用正常回归断言替代故障诊断预期。

怎么验证

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

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

最多三个 worker 被占时,其他状态请求仍应及时响应;队列超额连接须及时关闭并增加拒绝计数。四个 worker 都被占时仍会等待。

Wang Hao and others added 9 commits October 29, 2026 16:00
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.
…ist-version test

If the gate fetches the new list after the hub installs it and before the test reads the metrics, the assertion that the gate became stale does not hold. Pausing the gate while the hub changes its list removes that window.
Port 8444 served one connection at a time, so one client that stopped reading held /status and ticket fetches for every gate for seconds. It now hands accepted connections to a bounded queue of 16 served by four workers, closes and counts a connection when the queue is full, and keeps the 2 s step and 10 s connection deadlines. Port 8081 stays one thread for staff. The TLS slow-reader check in the status deadline test described the one-thread behaviour: status waited until the slow reader was cut; it now requires an answer within 1 s.
@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Ingrid Larsen · reviewer

Does adding four workers remove every head-of-line delay?


增加四个 worker 能消除所有排队延迟吗?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Ben Carter · author

No. It isolates the expected smaller number of stalled gates, but four occupied workers still exhaust capacity. The queue and deadlines bound that situation.


不能。它隔离预期数量较少的停滞闸机,但四个 worker 全被占仍会耗尽容量;队列和期限限制这种情况。

@TN019
TN019 merged commit 240c865 into main Dec 1, 2026
8 of 10 checks passed
@TN019
TN019 deleted the fix/tls-status-worker-pool branch December 1, 2026 02:58
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