[PATCH 1/1] Fix config reloading race

Adam Langley agl at google.com
Thu Sep 14 22:20:02 UTC 2006

Dear bind users,

At Google we have found the following patch to be helpful:
--- mem.c  2006-09-14 13:43:45.000000000 -0700
+++ mem.c       2006-09-14 13:43:50.000000000 -0700
@@ -1471,13 +1471,11 @@
               ctx->water_arg = NULL;
               ctx->hi_water = 0;
               ctx->lo_water = 0;
-               ctx->hi_called = ISC_FALSE;
       } else {
               ctx->water = water;
               ctx->water_arg = water_arg;
               ctx->hi_water = hiwater;
               ctx->lo_water = lowater;
-               ctx->hi_called = ISC_FALSE;
       MCTXUNLOCK(ctx, &ctx->lock);

(patch against lib/isc. Line numbers are for 9.4.0b2, but the same
issue exists in, at least, 9.3)

The failure mode is that the server pegs its CPU at 100% and no longer
caches any information. See http://tinyurl.com/evr3s for an example of
someone else reporting this failure.

The series of events appears to be:
 1. The cache allocates memory and pushes itself over the high-water
mark, leading to a water callback (isc__mem_get, isc/mem.c:1100;
water, dns/cache.c:976)
 2. The callback causes the cache to enter an overmem condition and
start cleaning
 3. The config is reloaded and the cache's memory settings are
reloaded (dns_cache_setcachesize, dns/cache.c:1028)
 4. The hi_called flag is reset (isc/mem.c:1471)
 5. The cache's cleaning causes the memory usage to fall below the
low-water mark, but because the hi_called flag is false, the callback
is never triggered.
 6. The cache continues to clean itself, pegging the CPU at 100%. Any
new entries in the cache are erased straight-away.

The patch above fixes step 4 and appears to work fine.



More information about the bind-users mailing list