Cloudflare的开源项目celld引入了确定性模拟测试(DST)这一方法论,用于检测分布式系统中隐藏的并发缺陷1。该技术通过保持代码、配置和随机种子不变,确保每次测试执行顺序和结果完全相同,从而能够可靠地复现那些难以追踪的问题1。
celld是Cloudflare Workers和Durable Objects的本地运行时,其外部依赖仅限于S3兼容对象存储1。该模拟器可精细控制网络请求、存储操作、异步任务的执行顺序以及时间推进1。利用这一能力,团队发现了一个告警竞态条件bug:当删除10:00设置的告警后随后在10:05设置新告警时,如果旧告警的清理任务在新告警设置完成后才执行,就会误删新告警所需的唤醒条目,导致节点重启后告警丢失1。团队随后采取了修复方案——为每个新告警分配独立的对象存储条目,使旧条目的删除不再影响新告警的正常运作1。
Cloudflare's open-source project celld employs deterministic simulation testing (DST) to detect bugs in distributed systems by controlling the execution order of events and applying random seeds to reliably reproduce elusive concurrency issues 1. The celld runtime, which powers Cloudflare Workers and Durable Objects, requires only an S3-compatible object store as an external dependency 1. Through deterministic simulation testing, identical code, configuration, and random seeds produce completely consistent execution sequences and results 1.
The simulator provides fine-grained control over network requests, storage operations, asynchronous task execution order, and time progression, enabling teams to systematically expose timing-dependent flaws 1. One such bug involved a race condition in alert handling: when an alert scheduled for 10:00 was deleted and a new alert set for 10:05, a cleanup task from the old alert running after the new alert's creation could delete the wake-up entry required by the new alert, causing the alert to be lost after node restart 1. The Cloudflare team resolved this issue by assigning each new alert its own object store entry, ensuring that deletion of old entries would not affect newly created ones 1.
评论
还没有评论,欢迎留下第一条。