startTime = started() ? std::min(startTime, dirStartTime) : dirStartTime;
}
+/// handles the completion of zero or more post-rebuild storeCleanup() steps
+static void
+storeCleanupComplete()
+{
+ assert(StoreController::store_dirs_rebuilding == 1); // we are the last act
+ --StoreController::store_dirs_rebuilding;
+
+ if (store_digest)
+ storeDigestNoteStoreReady();
+}
+
static void
storeCleanup(void *)
{
debugs(20, Important(43), "Completed Validation Procedure" <<
Debug::Extra << "Validated " << validated << " Entries" <<
Debug::Extra << "store_swap_size = " << (Store::Root().currentSize()/1024.0) << " KB");
- --StoreController::store_dirs_rebuilding;
- assert(0 == StoreController::store_dirs_rebuilding);
if (opt_store_doublecheck && store_errors) {
fatalf("Quitting after finding %d cache index inconsistencies. " \
"cache index (at your own risk).\n", store_errors);
}
- if (store_digest)
- storeDigestNoteStoreReady();
+ storeCleanupComplete();
currentSearch = nullptr;
} else
assert(StoreController::store_dirs_rebuilding > 1);
--StoreController::store_dirs_rebuilding;
+ if (StoreController::store_dirs_rebuilding > 1)
+ return; // wait for more rebuilding cache_dirs to call us
- /*
- * When store_dirs_rebuilding == 1, it means we are done reading
- * or scanning all cache_dirs. Now report the stats and start
- * the validation (storeCleanup()) thread.
- */
+ // rebuilt all cache_dirs (if any)
- if (StoreController::store_dirs_rebuilding > 1)
+ safe_free(RebuildProgress);
+
+ if (!counts.started()) {
+ assert(!counts.scancount);
+ debugs(20, 5, "not responsible for rebuilding any cache_dirs: " << Config.cacheSwap.n_configured);
+ // we did not even try to load any entries so we skip storeCleanup()'s
+ // entry validation reports
+ storeCleanupComplete();
return;
+ }
const auto dt = tvSubDsec(counts.startTime, current_time);
debugs(20, Important(56), "Beginning Validation Procedure");
eventAdd("storeCleanup", storeCleanup, nullptr, 0.0, 1);
-
- xfree(RebuildProgress);
-
- RebuildProgress = nullptr;
}
/*
* When we parse the configuration and construct each swap dir,
* the construction of that raises the rebuild count.
*
- * This prevents us from trying to write clean logs until we
- * finished rebuilding - including after a reconfiguration that opens an
- * existing swapdir. The corresponding decrement * occurs in
- * storeCleanup(), when it is finished.
+ * This prevents us from trying to write clean logs until we finished
+ * rebuilding - including after a reconfiguration that opens an existing
+ * swapdir. The corresponding decrement occurs in storeCleanupComplete().
*/
RebuildProgress = (store_rebuild_progress *)xcalloc(Config.cacheSwap.n_configured,
sizeof(store_rebuild_progress));