#include "globals.h"
#include "md5.h"
#include "sbuf/Stream.h"
+#include "SquidMath.h"
#include "Store.h"
#include "tools.h"
}
void
-Rock::Rebuild::failure(const char *msg, int errNo)
+Rock::Rebuild::callException(const std::exception &)
{
+ // For now, treat all Rebuild exceptions as fatal errors rather than letting
+ // the default callException() implementation to silently stop this job.
+ throw;
+}
+
+/// a helper to handle rebuild-killing I/O errors
+void
+Rock::Rebuild::failure(const char * const msg, const int errNo)
+{
+ assert(sd);
debugs(47,5, sd->index << " slot " << loadingPos << " at " <<
dbOffset << " <= " << dbSize);
+ SBufStream error;
+ error << "Cannot rebuild rock cache_dir index for " << sd->filePath <<
+ Debug::Extra << "problem: " << msg;
if (errNo)
- debugs(47, DBG_CRITICAL, "ERROR: Rock cache_dir rebuild failure: " << xstrerr(errNo));
- debugs(47, DBG_CRITICAL, "Do you need to run 'squid -z' to initialize storage?");
+ error << Debug::Extra << "I/O error: " << xstrerr(errNo);
+ error << Debug::Extra << "scan progress: " << Math::int64Percent(loadingPos, dbSlotLimit) << '%';
- assert(sd);
- fatalf("Rock cache_dir[%d] rebuild of %s failed: %s.",
- sd->index, sd->filePath, msg);
+ throw TextException(error.buf(), Here());
}
/// adds slot to the free slot index
/// \returns whether the indexing was necessary (and, hence, started)
static bool Start(SwapDir &dir);
+ /* AsyncJob API */
+ virtual void callException(const std::exception &) override;
+
protected:
/// whether the current kid is responsible for rebuilding the given cache_dir
static bool IsResponsible(const SwapDir &);