Repository navigation
test(gate-hub): hold gate refresh during stale-state observation - #171
Merged
Merged
Conversation
… 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.
…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.
Contributor
Author
|
Mateo Rossi · reviewer Could an assertion failure leave the gate stopped? 断言失败会不会把闸机一直留在停止状态? |
Contributor
Author
|
Noah Williams · author The finally block sends SIGCONT if the process is still alive, so the cleanup path does not depend on the assertion succeeding. 只要进程仍存在,finally 块就发送 SIGCONT,恢复步骤不依赖断言成功。 |
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
The gate may fetch the new list before the test reads its stale metric, making the observation race with refresh.
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 '^(gate_list_version)$' --output-on-failureThe test must observe stale while the gate is stopped and continue normally after resuming it.
背景
测试读取 stale 指标之前,闸机可能已经下载新票单,使观测与刷新发生竞态。
改动
怎么验证
在 Linux 环境安装
Dockerfile.build列出的构建依赖后,从仓库根目录运行:cmake --preset debug cmake --build --preset debug ctest --preset debug -R '^(gate_list_version)$' --output-on-failure测试应在闸机停止期间观测到 stale,恢复进程后继续正常运行。