refactor(dns): enhance cache safety, optimize performance, and refactor query logic#5248
refactor(dns): enhance cache safety, optimize performance, and refactor query logic#5248
Conversation
|
? |
8c0ea12 to
10d4562
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
This commit doesn't work correctly. After running for 5-10mins it stops resolving domains that were working before and just gives nxdomain errors e.g github.com .Please check. |
|
@t-e-s-tweb 感谢测试!这是一个严重问题,我会在今天晚上再次 review 它 |
|
@t-e-s-tweb 我已经修好了,测试后没发现问题,保险起见请你再测试一下 当缓存中同时存在 A + AAAA 且一个过期另一个没有时 因为误认为已命中缓存因此永远不会刷新记录,直到 A + AAAA 同时过期后被 5 分钟一次的 cleanup 清理掉 这个 BUG 是我防御式编程引发的 |
This comment was marked as resolved.
This comment was marked as resolved.
6。怪不得我有时候失去 A 或 AAAA 结果,还以为是网络错误😇 |
双栈请求,若 A + AAAA 缓存全部过期 如果一个过期另一个还剩一秒 |
26b70be to
bba947d
Compare
|
|
|
DNS 的三个 PR 在我这 UDP + TPROXY 环境下跑了快一个月了 |
此 PR 具体干了这些事:
PS:
现在先 publish(t1) 再 write cache(t2) 的机制,可能有极低概率导致 test...withcache 失败。
因为在 t1->t2 时隙 test 启动了第二次查询结果 miss cache。
其实没大问题因为时隙间所有请求都会被 singleflight 保护,最坏情况无非是迟迟无法命中缓存,导致每 rtt 都回源一次。
在目前 cache map 是全局锁的情况下,这已经是最优解了。之所以不让 test sleep 5s 单纯是想看看概率。
改动比较多,如果不好 review 可进一步拆成几个 PR
缓存重构(#5248)、乐观缓存(#5237)、并发查询(#5239)
三个 PR 相互冲突,如果全部接受得按这个顺序 merge
我好 rebase