...
 
Commits (1)
  • Kevin Chen's avatar
    Remove setting rdataset->ttl to 0. When it is set to 0, stale records · da9fcfea
    Kevin Chen authored
    in "rndc dumpdb" output show 0 TTLs.
    
    Add rbtdb->serve_stale_ttl to various checks so that stale records are
    not purged from the cache when they've been stale for RBTDB_VIRTUAL
    (300) seconds.
    
    Increment ns_statscounter_usedstale when a stale answer is used.
    
    There's a question of whether overmem_purge should be purging ancient
    records, instead of stale ones.  I've left it as purging stale
    records, since stale records could take up the majority of the cache.
    da9fcfea
......@@ -3320,7 +3320,6 @@ bind_rdataset(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node,
rdataset->attributes |= DNS_RDATASETATTR_PREFETCH;
if (STALE(header)) {
rdataset->attributes |= DNS_RDATASETATTR_STALE;
rdataset->ttl = 0;
}
rdataset->private1 = rbtdb;
rdataset->private2 = node;
......@@ -5653,7 +5652,8 @@ expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now) {
isc_rwlocktype_write);
for (header = rbtnode->data; header != NULL; header = header->next)
if (header->rdh_ttl <= now - RBTDB_VIRTUAL) {
if (header->rdh_ttl + rbtdb->serve_stale_ttl <=
now - RBTDB_VIRTUAL) {
/*
* We don't check if refcurrent(rbtnode) == 0 and try
* to free like we do in cache_find(), because
......@@ -5909,7 +5909,8 @@ cache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
for (header = rbtnode->data; header != NULL; header = header_next) {
header_next = header->next;
if (!ACTIVE(header, now)) {
if ((header->rdh_ttl < now - RBTDB_VIRTUAL) &&
if ((header->rdh_ttl + rbtdb->serve_stale_ttl <
now - RBTDB_VIRTUAL) &&
(locktype == isc_rwlocktype_write ||
NODE_TRYUPGRADE(lock) == ISC_R_SUCCESS)) {
/*
......@@ -6951,9 +6952,11 @@ addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
cleanup_dead_nodes(rbtdb, rbtnode->locknum);
header = isc_heap_element(rbtdb->heaps[rbtnode->locknum], 1);
if (header && header->rdh_ttl < now - RBTDB_VIRTUAL)
if (header && header->rdh_ttl +
rbtdb->serve_stale_ttl < now - RBTDB_VIRTUAL) {
expire_header(rbtdb, header, tree_locked,
expire_ttl);
}
/*
* If we've been holding a write lock on the tree just for
......
......@@ -5415,6 +5415,7 @@ query_lookup(query_ctx_t *qctx) {
STALE(qctx->rdataset)) {
qctx->rdataset->ttl =
qctx->client->view->staleanswerttl;
inc_stats(qctx->client, ns_statscounter_usedstale);
success = ISC_TRUE;
} else {
success = ISC_FALSE;
......