Opened 6 years ago

Closed 6 years ago

#1511 closed defect (fixed)

multiple resolver would retry others when someone fails

Reported by: crasyangel.lhy@… Owned by: Ruslan Ermilov
Priority: minor Milestone:
Component: other Version: 1.13.x
Keywords: Cc:
uname -a: 2.6.32
nginx -V: nginx version: nginx/1.12.2 built by gcc 4.8.2 (GCC) built with OpenSSL 1.0.2h 3 May 2016 TLS SNI support enabled

Description

As mdounin mentioned, the resolver_timeout directive controls hard limit on the total DNS resolution time. If not answered, DNS queries are resent (to a different server if configured) each 5 seconds, see here:https://trac.nginx.org/nginx/browser/nginx/src/core/ngx_resolver.c#L197. There is no way to configure this timeout though, as this doesn't seem to be needed in most cases in practice.

To make sure DNS queries are resent to a different server if one the configured servers is down, consider using resolver_timeout set to something like 6s or more.

I set resolver_timeout to 10s, but when ngx_resolver_send_query fails, resolver do not retry, see here:https://trac.nginx.org/nginx/browser/nginx/src/core/ngx_resolver.c#L855, the code goto failed, return ERROR and clean events

Attachments (1)

patch (1.3 KB ) - added by Ruslan Ermilov 6 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by crasyangel.lhy@…, 6 years ago

I set resolver_timeout to 10s, but when ngx_resolver_send_query fails, resolver do not retry, see here:https://trac.nginx.org/nginx/browser/nginx/src/core/ngx_resolver.c#L855, the code goto failed, return ERROR and clean events

So multiple resolver do not retry others when someone fails

Version 0, edited 6 years ago by crasyangel.lhy@… (next)

by Ruslan Ermilov, 6 years ago

Attachment: patch added

comment:2 by Ruslan Ermilov, 6 years ago

Owner: set to Ruslan Ermilov
Status: newassigned

Try the attached patch.

in reply to:  2 comment:3 by crasyangel.lhy@…, 6 years ago

Replying to ru:

Try the attached patch.

Good Job

comment:4 by Ruslan Ermilov, 6 years ago

Could you please provide us with the exact use case that you faced with, including the relevant error_log messages and possibly the config snippet?

comment:5 by Maxim Dounin <mdounin@…>, 6 years ago

In 7312:54683f650cbd/nginx:

Resolver: retry sending queries on errors (ticket #1511).

Errors when sending UDP datagrams can happen, e.g., when local IP address
changes (see fa0e093b64d7), or an unavailable DNS server on the LAN can cause
send() to fail with EHOSTDOWN on BSD systems. If this happens during
initial query, retry sending immediately, to a different DNS server when
possible. If this is not enough, allow normal resend to happen by ignoring
the return code of the second ngx_resolver_send_query() call, much like we
do in ngx_resolver_resend().

comment:6 by Maxim Dounin, 6 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.