When a DnsEntry becomes stale (i.e. older than the configured dns-ttl) it is enqueued to the resolver queue and the exiting entry is returned to the caller.
However, until the resolver has processed the corresponding DnsResolveRequest and updated the DnsEntry, the existing entry has the original timestamp and so will be requeued every time it is accessed.
As the queue is bounded (RESOLVER_MAX_QUEUE_SIZE set to 100) and the queue put time has a timeout (RESOLVER_QUEUE_TIMEOUT set to 10ms) then it will fill up quickly with duplicate entries and eventually some items will fail to be added to the queue and thus resulting in the entry being set to DnsEntry::Timeout.
The solution to is to update the timestamp of the DnsEntry as soon as it is enqueued to prevent it from being enqueued multiple times. Note that the timestamp will be updated again once the resolver queue processes it.
Aside: DnsEntry::Timeout has two meanings, the first is as above (timeout attempting to enqueue an entry) and the second is if the underlying resolver times out during resolution. It may be sensible to distinguish between these cases.
Hostnames briefly changing to
Timeout: xxx
then eventually corrects.This is a bug introduced in 0.11.0 in https://github.com/fujiapple852/trippy/issues/1233
When a
DnsEntry
becomes stale (i.e. older than the configureddns-ttl
) it is enqueued to the resolver queue and the exiting entry is returned to the caller.However, until the resolver has processed the corresponding
DnsResolveRequest
and updated theDnsEntry
, the existing entry has the original timestamp and so will be requeued every time it is accessed.As the queue is bounded (
RESOLVER_MAX_QUEUE_SIZE
set to 100) and the queue put time has a timeout (RESOLVER_QUEUE_TIMEOUT
set to 10ms) then it will fill up quickly with duplicate entries and eventually some items will fail to be added to the queue and thus resulting in the entry being set toDnsEntry::Timeout
.The solution to is to update the timestamp of the
DnsEntry
as soon as it is enqueued to prevent it from being enqueued multiple times. Note that the timestamp will be updated again once the resolver queue processes it.Aside:
DnsEntry::Timeout
has two meanings, the first is as above (timeout attempting to enqueue an entry) and the second is if the underlying resolver times out during resolution. It may be sensible to distinguish between these cases.