Repository navigation
fix(gate-hub): isolate TLS status requests with bounded workers - #172
Merged
Merged
Conversation
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.
Contributor
Author
|
Ingrid Larsen · reviewer Does adding four workers remove every head-of-line delay? 增加四个 worker 能消除所有排队延迟吗? |
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 全被占仍会耗尽容量;队列和期限限制这种情况。 |
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.
Why
A single stalled TLS download blocks unrelated gates despite per-connection deadlines.
What changed
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-failureStatus 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 下载停滞仍会阻塞其他闸机。
改动
怎么验证
在 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 都被占时仍会等待。