mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
Only start stale refresh window when resuming
If we did not attempt a fetch due to fetch-limits, we should not start the stale-refresh-time window. Introduce a new flag DNS_DBFIND_STALESTART to differentiate between a resolver failure and unexpected error. If we are resuming, this indicates a resolver failure, then start the stale-refresh-time window, otherwise don't start the stale-refresh-time window, but still fall back to using stale data. (This commit also wraps some docstrings to 80 characters width)
This commit is contained in:
@@ -241,33 +241,36 @@ struct dns_dbonupdatelistener {
|
|||||||
#define DNS_DBFIND_NOZONECUT 0x0200
|
#define DNS_DBFIND_NOZONECUT 0x0200
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DNS_DBFIND_STALEOK: This flag is set when BIND fails to refresh a
|
* DNS_DBFIND_STALEOK: This flag is set when BIND fails to refresh a RRset due
|
||||||
* RRset due to timeout (resolver-query-timeout), its intent is to
|
* to timeout (resolver-query-timeout). Its intent is to try to look for stale
|
||||||
* try to look for stale data in cache as a fallback, but only if
|
* data in cache as a fallback, but only if stale answers are enabled in
|
||||||
* stale answers are enabled in configuration.
|
* configuration.
|
||||||
*
|
|
||||||
* This flag is also used to activate stale-refresh-time window, since it
|
|
||||||
* is the only way the database knows that a resolution has failed.
|
|
||||||
*/
|
*/
|
||||||
#define DNS_DBFIND_STALEOK 0x0400
|
#define DNS_DBFIND_STALEOK 0x0400
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DNS_DBFIND_STALEENABLED: This flag is used as a hint to the database
|
* DNS_DBFIND_STALEENABLED: This flag is used as a hint to the database that
|
||||||
* that it may use stale data. It is always set during query lookup if
|
* it may use stale data. It is always set during query lookup if stale
|
||||||
* stale answers are enabled, but only effectively used during
|
* answers are enabled, but only effectively used during stale-refresh-time
|
||||||
* stale-refresh-time window. Also during this window, the resolver will
|
* window. Also during this window, the resolver will not try to resolve the
|
||||||
* not try to resolve the query, in other words no attempt to refresh the
|
* query, in other words no attempt to refresh the data in cache is made when
|
||||||
* data in cache is made when the stale-refresh-time window is active.
|
* the stale-refresh-time window is active.
|
||||||
*/
|
*/
|
||||||
#define DNS_DBFIND_STALEENABLED 0x0800
|
#define DNS_DBFIND_STALEENABLED 0x0800
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DNS_DBFIND_STALEONLY: This new introduced flag is used when we want
|
* DNS_DBFIND_STALEONLY: This flag is used when we want stale data from the
|
||||||
* stale data from the database, but not due to a failure in resolution,
|
* database, but not due to a failure in resolution, it also doesn't require
|
||||||
* it also doesn't require stale-refresh-time window timer to be active.
|
* stale-refresh-time window timer to be active. As long as there is a stale
|
||||||
* As long as there is a stale RRset available, it should be returned.
|
* RRset available, it should be returned.
|
||||||
*/
|
*/
|
||||||
#define DNS_DBFIND_STALEONLY 0x1000
|
#define DNS_DBFIND_STALEONLY 0x1000
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DNS_DBFIND_STALESTART: This flag is used to activate stale-refresh-time
|
||||||
|
* window.
|
||||||
|
*/
|
||||||
|
#define DNS_DBFIND_STALESTART 0x2000
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/*@{*/
|
/*@{*/
|
||||||
|
@@ -4565,11 +4565,12 @@ check_stale_header(dns_rbtnode_t *node, rdatasetheader_t *header,
|
|||||||
mark_header_stale(search->rbtdb, header);
|
mark_header_stale(search->rbtdb, header);
|
||||||
*header_prev = header;
|
*header_prev = header;
|
||||||
/*
|
/*
|
||||||
* If DNS_DBFIND_STALEOK is set then it means we failed
|
* If DNS_DBFIND_STALESTART is set then it means we
|
||||||
* to resolve the name during recursion, in this case we
|
* failed to resolve the name during recursion, in
|
||||||
* mark the time in which the refresh failed.
|
* this case we mark the time in which the refresh
|
||||||
|
* failed.
|
||||||
*/
|
*/
|
||||||
if ((search->options & DNS_DBFIND_STALEOK) != 0) {
|
if ((search->options & DNS_DBFIND_STALESTART) != 0) {
|
||||||
header->last_refresh_fail_ts = search->now;
|
header->last_refresh_fail_ts = search->now;
|
||||||
} else if ((search->options &
|
} else if ((search->options &
|
||||||
DNS_DBFIND_STALEENABLED) != 0 &&
|
DNS_DBFIND_STALEENABLED) != 0 &&
|
||||||
|
@@ -7560,7 +7560,15 @@ query_gotanswer(query_ctx_t *qctx, isc_result_t res) {
|
|||||||
/*
|
/*
|
||||||
* If serve-stale is enabled, query_usestale() already
|
* If serve-stale is enabled, query_usestale() already
|
||||||
* set up 'qctx' for looking up a stale response.
|
* set up 'qctx' for looking up a stale response.
|
||||||
|
*
|
||||||
|
* We only need to check if the query timed out or
|
||||||
|
* something else has gone wrong. If the query timed
|
||||||
|
* out, we will start the stale-refresh-time window.
|
||||||
*/
|
*/
|
||||||
|
if (qctx->resuming && result == ISC_R_TIMEDOUT) {
|
||||||
|
qctx->client->query.dboptions |=
|
||||||
|
DNS_DBFIND_STALESTART;
|
||||||
|
}
|
||||||
return (query_lookup(qctx));
|
return (query_lookup(qctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user