You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-1222 - improved the waitforsystemactive function
This commit is contained in:
@ -8833,6 +8833,92 @@ namespace oam
|
||||
return entry;
|
||||
}
|
||||
|
||||
/******************************************************************************************
|
||||
* @brief waitForActive
|
||||
*
|
||||
* purpose: wait for system to be active
|
||||
*
|
||||
******************************************************************************************/
|
||||
void Oam::waitForActive()
|
||||
{
|
||||
SystemStatus systemstatus;
|
||||
SystemProcessStatus systemprocessstatus;
|
||||
bool bfirst = true;
|
||||
|
||||
for (int i = 0 ; i < 18 ; i ++)
|
||||
{
|
||||
sleep (10);
|
||||
try
|
||||
{
|
||||
getSystemStatus(systemstatus);
|
||||
if (systemstatus.SystemOpState == ACTIVE)
|
||||
{
|
||||
BRM::DBRM dbrm;
|
||||
try {
|
||||
int rc = dbrm.getSystemQueryReady();
|
||||
if (rc == -1 ) {
|
||||
writeLog("waitForActive: getSystemQueryReady error return: startSystem failed", LOG_TYPE_ERROR);
|
||||
exceptionControl("waitForActive", API_FAILURE);
|
||||
}
|
||||
|
||||
if ( rc != 0 )
|
||||
return;
|
||||
|
||||
writeLog("waitForActive: getSystemQueryReady not ready", LOG_TYPE_DEBUG);
|
||||
}
|
||||
catch(...)
|
||||
{}
|
||||
}
|
||||
|
||||
if (systemstatus.SystemOpState == FAILED)
|
||||
{
|
||||
exceptionControl("waitForActive", API_FAILURE);
|
||||
}
|
||||
|
||||
if (systemstatus.SystemOpState == MAN_OFFLINE)
|
||||
{
|
||||
exceptionControl("waitForActive", API_FAILURE);
|
||||
}
|
||||
|
||||
cout << "." << flush;
|
||||
|
||||
// Check DMLProc for a switch to BUSY_INIT.
|
||||
// In such a case, we need to print a message that rollbacks
|
||||
// are occurring and will take some time.
|
||||
if (bfirst) // Once we've printed our message, no need to waste cpu looking
|
||||
{
|
||||
getProcessStatus(systemprocessstatus);
|
||||
for (unsigned int i = 0 ; i < systemprocessstatus.processstatus.size(); i++)
|
||||
{
|
||||
if (systemprocessstatus.processstatus[i].ProcessName == "DMLProc")
|
||||
{
|
||||
if (systemprocessstatus.processstatus[i].ProcessOpState == oam::ROLLBACK_INIT)
|
||||
{
|
||||
cout << endl << endl <<" System Not Ready, DMLProc is checking/processing rollback of abandoned transactions. Processing could take some time, please wait..." << flush;
|
||||
bfirst = false;
|
||||
}
|
||||
// At this point, we've found our DMLProc, so there's no need to spin the for loop
|
||||
// any further.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// At some point, we need to give up, ProcMon just isn't going to respond.
|
||||
if (i > 18) // 3 minutes
|
||||
{
|
||||
cout << endl << endl << "TIMEOUT: ProcMon not responding to getSystemStatus";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exceptionControl("waitForActive", API_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* PRIVATE FUNCTIONS
|
||||
***************************************************************************/
|
||||
|
@ -2481,6 +2481,10 @@ namespace oam
|
||||
|
||||
bool checkSystemRunning();
|
||||
|
||||
/** @brief wait for system to be active
|
||||
*/
|
||||
EXPORT void waitForActive();
|
||||
|
||||
private:
|
||||
|
||||
int sendMsgToProcMgr3(messageqcpp::ByteStream::byte requestType, alarmmanager::AlarmList& alarmlist, const std::string date);
|
||||
|
@ -77,62 +77,13 @@ bool SendToWES(Oam& oam, ByteStream bs);
|
||||
bool waitForActive()
|
||||
{
|
||||
Oam oam;
|
||||
SystemStatus systemstatus;
|
||||
SystemProcessStatus systemprocessstatus;
|
||||
bool bfirst = true;
|
||||
|
||||
for (int i = 0 ; i < 1200 ; i ++)
|
||||
{
|
||||
sleep (3);
|
||||
try
|
||||
{
|
||||
oam.getSystemStatus(systemstatus);
|
||||
if (systemstatus.SystemOpState == ACTIVE)
|
||||
{
|
||||
oam.waitForActive();
|
||||
return true;
|
||||
}
|
||||
if (systemstatus.SystemOpState == FAILED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (systemstatus.SystemOpState == MAN_OFFLINE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
cout << "." << flush;
|
||||
|
||||
// Check DMLProc for a switch to BUSY_INIT.
|
||||
// In such a case, we need to print a message that rollbacks
|
||||
// are occurring and will take some time.
|
||||
if (bfirst) // Once we've printed our message, no need to waste cpu looking
|
||||
{
|
||||
oam.getProcessStatus(systemprocessstatus);
|
||||
for (unsigned int i = 0 ; i < systemprocessstatus.processstatus.size(); i++)
|
||||
{
|
||||
if (systemprocessstatus.processstatus[i].ProcessName == "DMLProc")
|
||||
{
|
||||
if (systemprocessstatus.processstatus[i].ProcessOpState == oam::ROLLBACK_INIT)
|
||||
{
|
||||
cout << endl << endl <<" System Not Ready, DMLProc is checking/processing rollback of abandoned transactions. Processing could take some time, please wait..." << flush;
|
||||
bfirst = false;
|
||||
}
|
||||
// At this point, we've found our DMLProc, so there's no need to spin the for loop
|
||||
// any further.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// At some point, we need to give up, ProcMgr just isn't going to respond.
|
||||
if (i > 60) // 3 minutes
|
||||
{
|
||||
cout << "ProcMgr not responding while waiting for system to start";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -74,28 +74,21 @@ void callFree(const char* )
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool waitForActive()
|
||||
{
|
||||
Oam oam;
|
||||
|
||||
const string cmd = installDir + "/bin/mcsadmin getsystemstatus > /tmp/wait.log";
|
||||
system(cmd.c_str());
|
||||
|
||||
for ( int i = 0 ; i < 120 ; i ++ )
|
||||
try
|
||||
{
|
||||
if (oam.checkLogStatus("/tmp/wait.log", "System ACTIVE") )
|
||||
oam.waitForActive();
|
||||
return true;
|
||||
if ( oam.checkLogStatus("/tmp/wait.log", "System FAILED") )
|
||||
return false;
|
||||
cout << ".";
|
||||
cout.flush();
|
||||
sleep (10);
|
||||
system(cmd.c_str());
|
||||
}
|
||||
catch (...)
|
||||
{}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void dbrmDirCheck()
|
||||
{
|
||||
|
||||
|
Reference in New Issue
Block a user