Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

用sequence模拟fallback,出现context deadline exceeded时程序会中断。 #800

Open
blog2i2j opened this issue Mar 12, 2024 · 4 comments

Comments

@blog2i2j
Copy link

我用sequence模拟fallback,在某个DNS不通的时候,就会出现context deadline exceeded报错,然后程序就会再往下运行导致DNS无法解析了。
恳求修复网络引起的context deadline exceeded时能够按照不能获取继续往下正常流转程序。

===================================================
以下是原文

用途,某些内网域名先用内网DNS解析, 如果解析不成功再使用外网解析(内部域名内外网都可用,入口不同)
现在想先用10.66.60.22解析,不成功换119.29.29.29解析,内网解析没有问题。到外网的时候,结果都是在10.66这步结束了。程序不再流下去。

log:
  production: false
  level: info

plugins:

  - tag: "company_domain"
    type: domain_set
    args:
      files: "./company_domain.txt"

  - tag: "local_cn_forward"
    type: forward
    args:
        upstreams:
          - addr: "119.29.29.29"

  - tag: "company_forward"
    type: forward
    args:
        upstreams:
          - addr: "10.66.60.22"

  - tag: "company_sequence"
    type: sequence
    args:
      - exec: $company_forward
      - exec: query_summary

  - tag: "local_cn_sequence"
    type: sequence
    args:
      - exec: $local_cn_forward

  - tag: "company_sequence_1"
    type: sequence
    args:

      - exec: jump company_sequence
      - matches: "!has_resp"
        exec: jump local_cn_sequence


#main sequence
  - tag: "main_sequence"
    type: sequence
    args:
      - exec: prefer_ipv4

      #match company domain
      - matches: "qname $company_domain"
        exec: jump company_sequence_1


#dns server
  - tag: udp_server
    type: udp_server
    args:
      entry: main_sequence
      listen: 127.0.0.1:353

log如下:
2024-03-11T17:09:51.922+0800 WARN udp_server entry err {"query": {"uqid": 1, "client": "127.0.0.1", "qname": "s04.sdec.com.", "qtype": 1, "qclass": 1, "elapsed": "5.0131446s"}, "edes": [{"info_code": 0, "extra_text": "context deadline exceeded"}]}
2024-03-11T17:09:51.922+0800 WARN company_forward upstream error {"uqid": 1, "qname": "s04.sdec.com.", "qtype": 1, "qclass": 1, "upstream": "10.66.60.22", "error": "context deadline exceeded"}
2024-03-11T17:09:56.923+0800 WARN company_forward upstream error {"uqid": 2, "qname": "s04.sdec.com.", "qtype": 1, "qclass": 1, "upstream": "10.66.60.22", "error": "context deadline exceeded"}
2024-03-11T17:09:56.923+0800 WARN udp_server entry err {"query": {"uqid": 2, "client": "127.0.0.1", "qname": "s04.sdec.com.", "qtype": 1, "qclass": 1, "elapsed": "5.0002939s"}, "edes": [{"info_code": 0, "extra_text": "context deadline exceeded"}]}

Originally posted by @blog2i2j in #799

@sbwml
Copy link

sbwml commented Mar 12, 2024

如果稍微转圜一下呢?比如:

log:
  production: false
  level: info

plugins:

  - tag: "company_domain"
    type: domain_set
    args:
      files: "./company_domain.txt"

  - tag: "local_cn_forward"
    type: forward
    args:
        upstreams:
          - addr: "119.29.29.29"

  - tag: "company_forward"
    type: forward
    args:
        upstreams:
          - addr: "10.66.60.22"

  - tag: "company_sequence"
    type: sequence
    args:
      - exec: $company_forward
      - exec: query_summary

  - tag: "local_cn_sequence"
    type: sequence
    args:
      - exec: $local_cn_forward

  - tag: company_sequence_1
    type: fallback
    args:
      primary: company_sequence
      secondary: local_cn_sequence
      threshold: 500
      always_standby: true

#main sequence
  - tag: "main_sequence"
    type: sequence
    args:
      - exec: prefer_ipv4

      #match company domain
      - matches: "qname $company_domain"
        exec: $company_sequence_1


#dns server
  - tag: udp_server
    type: udp_server
    args:
      entry: main_sequence
      listen: 127.0.0.1:353

直接让命中 company_domain.txt 列表的域名走 fallback 策略,而 fallback 首先查询 10.66.60.22 ,在 500 毫秒内没有得到响应马上应答 119.29.29.29 的查询结果。

@blog2i2j
Copy link
Author

目前就是采用这个方案了, 这个方案就是配置要写的复杂很多.

@qingtian110
Copy link

fallback 的存在有一部分意思就是解决这个 issues 遇到的情况吧,换一个角度来说的话,如果要判断一个dns 是否有问题,那就是要用到超时,那么倒是超时多久才算这个 dns 上游有问题呢?2秒?3秒?还是5秒?我去访问一个页面,但是我使用了一个有问题的 dns,要打开这个网页必须要等超时时间后才能访问, 我想这肯定也不是你想要的结果。

fallback 倒是个非常好的解决方案,因为它能在毫秒级做出方案,上网体验几乎无感。

不过你这看着不像用于解析上网用途的 dns,因为你的配置文件来看这个非常不适合日常上网

@qingtian110
Copy link

mosdns v4 倒是有个来自 adg 的转发模块,它具备 timeout: 5 参数支持。它可以让你超时失败后继续走流程。

但这种方式绝对不是解决方法。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants