Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not report bogus/empty SMP cache_dir indexing stats #235

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions src/store_rebuild.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ StoreRebuildData::updateStartTime(const timeval &dirStartTime)
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 *)
{
Expand Down Expand Up @@ -100,8 +111,6 @@ 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. " \
Expand All @@ -110,8 +119,7 @@ storeCleanup(void *)
"cache index (at your own risk).\n", store_errors);
}

if (store_digest)
storeDigestNoteStoreReady();
storeCleanupComplete();

currentSearch = nullptr;
} else
Expand Down Expand Up @@ -141,15 +149,21 @@ storeRebuildComplete(StoreRebuildData *dc)

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);

Expand All @@ -167,10 +181,6 @@ storeRebuildComplete(StoreRebuildData *dc)
debugs(20, Important(56), "Beginning Validation Procedure");

eventAdd("storeCleanup", storeCleanup, nullptr, 0.0, 1);

xfree(RebuildProgress);

RebuildProgress = nullptr;
}

/*
Expand All @@ -188,10 +198,9 @@ storeRebuildStart(void)
* 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));
Expand Down