]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3551: store_rebuild.cc:116: "store_errors == 0" assertion
authorAlex Rousskov <rousskov@measurement-factory.com>
Sat, 21 Jul 2012 01:16:32 +0000 (19:16 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 21 Jul 2012 01:16:32 +0000 (19:16 -0600)
Fail with an explanation instead of asserting. The assertion fails when a ufs
cache_dir's swap.state has inconsistencies AND the user starts Squid with a -S
command line option. Normally, such inconsistencies are ignored and many of
them are benign.  For example, a missing cache file with an ADD record in
swap.state is such an inconsistency.

The -S option was meant to help developers troubleshoot inconsistencies by
analyzing core dumps, but (a) admins treat assertions as Squid bugs and file
bug reports and (b) in most cases, it is really difficult to find the
inconsistency when Squid asserts after detecting all of them (and leaving the
detection context).

We now explicitly tell the admin what their options are and quit instead of
asserting.

TODO: Consider adding a ufs cache_dir option that checks for and removes
inconsistencies instead of not checking at all (default) or checking and
quitting (-S). This is difficult because some valid cache entries may look
inconsistent while they are being updated and some invalid cache entries
are not visible to Squid without a full directory scan.

src/store_rebuild.cc

index 521cf26b689bb62d7ac9bc9d6f47acf97edd005a..e52280a40996ccac5f06da03956f31788a7539bf 100644 (file)
@@ -112,8 +112,12 @@ storeCleanup(void *datanotused)
         StoreController::store_dirs_rebuilding--;
         assert(0 == StoreController::store_dirs_rebuilding);
 
-        if (opt_store_doublecheck)
-            assert(store_errors == 0);
+        if (opt_store_doublecheck && store_errors) {
+            fatalf("Quitting after finding %d cache index inconsistencies. " \
+                   "Removing cache index will force its slow rebuild. " \
+                   "Removing -S will let Squid start with an inconsistent " \
+                   "cache index (at your own risk).\n", store_errors);
+        }
 
         if (store_digest)
             storeDigestNoteStoreReady();