From f9e5bdbc8d2f519e5a8610062a514759f3702e9a Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Wed, 12 Feb 2020 09:57:22 +0000 Subject: [PATCH] Fix restart hang mcsadmin restart will do a status call. Before this would log status output to a file which would be checked. If that file check failed a PID check would be made. We do not log the status to a file any more since it could have multiple different outputs. The PID check could hit a race condition where it is being checked before the process is up. This would mean there is no module state change causing a hang. This fix does the following: 1. Remove the file status check completely 2. Loop the PID check to give it time to come up 3. If the PID check fails drop to a DEGRADED state This makes mcsadmin restart work correctly again. --- oam/oamcpp/liboamcpp.cpp | 55 +++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 4cfbc3d70..c0a020a10 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -7927,11 +7927,11 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action) getProcessStatus("mysqld", moduleName, procstat); int state = procstat.ProcessOpState; pid_t pidStatus = procstat.ProcessID; - + pid_t pid = 0; string mysqlStatus = tmpdir + "/mysql.status"; - if (checkLogStatus(mysqlStatus, "MySQL running")) + if ( state != ACTIVE ) { - if ( state != ACTIVE ) + for (int i=0; i < 10; i++) { //get pid char buf[512]; @@ -7942,17 +7942,26 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action) pclose( cmd_pipe ); - //set process status - try + if (pid) { - setProcessStatus("mysqld", moduleName, ACTIVE, pid); + //set process status + try + { + setProcessStatus("mysqld", moduleName, ACTIVE, pid); + } + catch (...) + {} + return; + } + else + { + sleep(2); } - catch (...) - {} - - return; } - else + } + else + { + for (int i=0; i < 10; i++) { //check if pid has changed char buf[512]; @@ -7963,18 +7972,28 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action) pclose( cmd_pipe ); - if ( pidStatus != pid ) + if (pid) { - //set process status - try + if ( pidStatus != pid ) { - setProcessStatus("mysqld", moduleName, ACTIVE, pid); + //set process status + try + { + setProcessStatus("mysqld", moduleName, ACTIVE, pid); + } + catch (...) + {} + break; } - catch (...) - {} + } + else + { + sleep(2); } } - + } + if (pid) + { //check module status, if DEGRADED set to ACTIVE int opState; bool degraded;