1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-05 15:41:14 +03:00

fix(syscat): MCOL-5816 23.02 -> 23.10 upgrade issues (#3346) (#3374)

* feat(BRM,tools): couple utilities to watch/operate shared memory locks and extent map

* feat(BRM,tools): merged two utilities and added some extra dbbuilder output in case of upgrade

* fix(dbbuilder): extra output to log upgrade detection.
This commit is contained in:
drrtuy
2024-12-26 16:26:34 +00:00
committed by GitHub
parent 50a9f82f76
commit dd8fac35ae
12 changed files with 339 additions and 446 deletions

View File

@ -84,12 +84,12 @@ void usage()
const unsigned sysCatalogErr = logging::M0060;
void errorHandler(const unsigned mid, const string& src, const string& msg, bool isCritErr = true)
void messageHandler(const string& src, const string& msg, bool isCritErr = true)
{
logging::LoggingID lid(19);
logging::MessageLog ml(lid);
logging::Message::Args args;
logging::Message message(mid);
logging::Message message(sysCatalogErr);
if (isCritErr)
{
@ -143,28 +143,6 @@ int main(int argc, char* argv[])
return 1;
}
oamModuleInfo_t t;
bool parentOAMModuleFlag = false;
// get local module info; validate running on Active Parent OAM Module
try
{
t = oam.getModuleInfo();
parentOAMModuleFlag = boost::get<4>(t);
}
catch (exception&)
{
parentOAMModuleFlag = true;
}
if (!parentOAMModuleFlag)
{
cerr << "Exiting, dbbuilder can only be run on the Active "
"Parent OAM Module"
<< endl;
return 1;
}
logFile = string(MCSLOGDIR) + "/install/dbbuilder.status";
buildOption = atoi(argv[optind++]);
@ -193,24 +171,21 @@ int main(int argc, char* argv[])
bool isUpgrade = false;
std::unordered_map<int, std::pair<int, bool>> upgradeOidMap;
upgradeOidMap[OID_SYSTABLE_AUXCOLUMNOID] = // This is the candidate OID for the upgrade.
std::make_pair(OID_SYSTABLE_OBJECTID, false); // std::pair::first is the reference OID used
// to fill the candidate OID with default vals
// std::pair::second is set to false by default
// which means the candidate OID will not be
// upgraded. This is set to true in the code
// below if a specific condition is met. Please
// note that the candidate and reference OID
// datatypes and colwidths are assumed to be the
// same in SystemCatalog::upgrade().
upgradeOidMap[OID_SYSCOLUMN_CHARSETNUM] =
std::make_pair(OID_SYSCOLUMN_OBJECTID, false);
upgradeOidMap[OID_SYSTABLE_AUXCOLUMNOID] = // This is the candidate OID for the upgrade.
std::make_pair(OID_SYSTABLE_OBJECTID, false); // std::pair::first is the reference OID used
// to fill the candidate OID with default vals
// std::pair::second is set to false by default
// which means the candidate OID will not be
// upgraded. This is set to true in the code
// below if a specific condition is met. Please
// note that the candidate and reference OID
// datatypes and colwidths are assumed to be the
// same in SystemCatalog::upgrade().
upgradeOidMap[OID_SYSCOLUMN_CHARSETNUM] = std::make_pair(OID_SYSCOLUMN_OBJECTID, false);
std::unordered_map<int, OidTypeT> upgradeOidTypeMap;
upgradeOidTypeMap[OID_SYSTABLE_AUXCOLUMNOID] =
std::make_pair(CalpontSystemCatalog::INT, 4);
upgradeOidTypeMap[OID_SYSCOLUMN_CHARSETNUM] =
std::make_pair(CalpontSystemCatalog::INT, 4);
upgradeOidTypeMap[OID_SYSTABLE_AUXCOLUMNOID] = std::make_pair(CalpontSystemCatalog::INT, 4);
upgradeOidTypeMap[OID_SYSCOLUMN_CHARSETNUM] = std::make_pair(CalpontSystemCatalog::INT, 4);
std::unordered_map<int, std::string> upgradeOidDefaultValStrMap;
upgradeOidDefaultValStrMap[OID_SYSTABLE_AUXCOLUMNOID] = "0";
@ -227,11 +202,12 @@ int main(int argc, char* argv[])
(iter->second).second = true;
isUpgrade = true;
}
messageHandler("", std::string("Upgrade flag is ") + std::to_string(isUpgrade) + std::string(" after checking upgrade candidate OID ") + oam.itoa(iter->first) + std::string(" "), false);
}
if (!isUpgrade)
{
string cmd = "echo 'FAILED: buildOption=" + oam.itoa(buildOption) + "' > " + logFile;
string cmd = "echo 'OK: buildOption=" + oam.itoa(buildOption) + "' > " + logFile;
if (canWrite)
{
@ -242,10 +218,10 @@ int main(int argc, char* argv[])
cerr << cmd << endl;
}
errorHandler(sysCatalogErr, "Build system catalog",
"System catalog appears to exist. It will remain intact "
"for reuse. The database is not recreated.",
false);
messageHandler("Build system catalog",
"System catalog appears to exist. It will remain intact "
"for reuse. The database is not recreated.",
false);
return 1;
}
}
@ -276,7 +252,7 @@ int main(int argc, char* argv[])
else
cerr << cmd << endl;
errorHandler(sysCatalogErr, "Build system catalog", ex.what(), false);
messageHandler("Build system catalog", ex.what(), false);
return 1;
}
catch (...)
@ -288,7 +264,7 @@ int main(int argc, char* argv[])
else
cerr << cmd << endl;
errorHandler(sysCatalogErr, "Build system catalog", "HDFS check failed.", false);
messageHandler("Build system catalog", "HDFS check failed.", false);
return 1;
}
@ -305,6 +281,15 @@ int main(int argc, char* argv[])
}
else
{
string cmd = "echo 'Upgrade system catalog' > " + logFile;
if (canWrite)
{
rc = system(cmd.c_str());
}
else
{
cerr << cmd << endl;
}
sysCatalog.upgrade(upgradeOidMap, upgradeOidTypeMap, upgradeOidDefaultValStrMap);
}
@ -326,7 +311,7 @@ int main(int argc, char* argv[])
ostringstream os;
os << "Warning: running " << cmd << " failed. This is usually non-fatal.";
cerr << os.str() << endl;
errorHandler(sysCatalogErr, "Save BRM", os.str());
messageHandler("Save BRM", os.str());
}
}
else
@ -343,7 +328,7 @@ int main(int argc, char* argv[])
else
cerr << cmd << endl;
errorHandler(sysCatalogErr, "Build system catalog", ex.what());
messageHandler("Build system catalog", ex.what());
}
catch (...)
{
@ -355,7 +340,7 @@ int main(int argc, char* argv[])
cerr << cmd << endl;
string err("Caught unknown exception!");
errorHandler(sysCatalogErr, "Build system catalog", err);
messageHandler("Build system catalog", err);
}
}
else