Commit aa1e2ab7 authored by unknown's avatar unknown

improve error message on corrup schema file

parent 35d17e61
......@@ -79,6 +79,9 @@
#include <NdbSleep.h>
#include <signaldata/ApiBroadcast.hpp>
#include <EventLogger.hpp>
extern EventLogger g_eventLogger;
#define ZNOT_FOUND 626
#define ZALREADYEXIST 630
......@@ -1070,26 +1073,34 @@ void Dbdict::readSchemaConf(Signal* signal,
for (Uint32 n = 0; n < xsf->noOfPages; n++) {
SchemaFile * sf = &xsf->schemaPage[n];
bool ok = false;
const char *reason;
if (memcmp(sf->Magic, NDB_SF_MAGIC, sizeof(sf->Magic)) != 0)
{ jam(); }
{ jam(); reason = "magic code"; }
else if (sf->FileSize == 0)
{ jam(); }
{ jam(); reason = "file size == 0"; }
else if (sf->FileSize % NDB_SF_PAGE_SIZE != 0)
{ jam(); }
{ jam(); reason = "invalid size multiple"; }
else if (sf->FileSize != sf0->FileSize)
{ jam(); }
{ jam(); reason = "invalid size"; }
else if (sf->PageNumber != n)
{ jam(); }
{ jam(); reason = "invalid page number"; }
else if (computeChecksum((Uint32*)sf, NDB_SF_PAGE_SIZE_IN_WORDS) != 0)
{ jam(); }
else if (crashInd)
{ jam(); }
{ jam(); reason = "invalid checksum"; }
else
ok = true;
ndbrequireErr(ok, NDBD_EXIT_SR_SCHEMAFILE);
if (! ok) {
if (!ok)
{
char reason_msg[128];
snprintf(reason_msg, sizeof(reason_msg),
"schema file corrupt, page %u (%s, "
"sz=%u sz0=%u pn=%u)",
n, reason, sf->FileSize, sf0->FileSize, sf->PageNumber);
if (crashInd)
progError(__LINE__, NDBD_EXIT_SR_SCHEMAFILE, reason_msg);
jam();
ndbrequire(fsPtr.p->fsState == FsConnectRecord::READ_SCHEMA1);
infoEvent("primary %s, trying backup", reason_msg);
readSchemaRef(signal, fsPtr);
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment