You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
MCOL-379 - fix false critical memory usage alarm
This commit is contained in:
@ -155,6 +155,7 @@ rm -f $installdir/data/bulk/tmpjob/* >/dev/null 2>&1
|
|||||||
|
|
||||||
#create columnstore temp file directory
|
#create columnstore temp file directory
|
||||||
$SUDO chmod 777 /tmp
|
$SUDO chmod 777 /tmp
|
||||||
|
$SUDO rm -f /tmp/* > /dev/null 2>&1
|
||||||
mkdir -p /tmp/columnstore_tmp_files >/dev/null 2>&1
|
mkdir -p /tmp/columnstore_tmp_files >/dev/null 2>&1
|
||||||
|
|
||||||
#setup core file directory and link
|
#setup core file directory and link
|
||||||
@ -213,7 +214,6 @@ if [ $user = "root" ]; then
|
|||||||
$installdir/bin/syslogSetup.sh install > /tmp/syslog_install.log 2>&1
|
$installdir/bin/syslogSetup.sh install > /tmp/syslog_install.log 2>&1
|
||||||
rm -f /etc/default/columnstore
|
rm -f /etc/default/columnstore
|
||||||
else
|
else
|
||||||
$SUDO rm -fr /tmp/* > /dev/null 2>&1
|
|
||||||
$installdir/bin/syslogSetup.sh --installdir=$installdir install > /tmp/syslog_install.log 2>&1
|
$installdir/bin/syslogSetup.sh --installdir=$installdir install > /tmp/syslog_install.log 2>&1
|
||||||
$SUDO chown $user:$user $installdir/etc/Columnstore.xml
|
$SUDO chown $user:$user $installdir/etc/Columnstore.xml
|
||||||
$SUDO chmod -R 777 /dev/shm
|
$SUDO chmod -R 777 /dev/shm
|
||||||
|
@ -32,10 +32,11 @@ using namespace logging;
|
|||||||
using namespace servermonitor;
|
using namespace servermonitor;
|
||||||
//using namespace procheartbeat;
|
//using namespace procheartbeat;
|
||||||
|
|
||||||
unsigned long totalMem;
|
|
||||||
ProcessMemoryList pml;
|
ProcessMemoryList pml;
|
||||||
int swapFlag = 0;
|
int swapFlag = 0;
|
||||||
|
|
||||||
|
uint64_t totalMem;
|
||||||
|
|
||||||
pthread_mutex_t MEMORY_LOCK;
|
pthread_mutex_t MEMORY_LOCK;
|
||||||
|
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
@ -62,7 +63,7 @@ void memoryMonitor()
|
|||||||
|
|
||||||
//set monitoring period to 60 seconds
|
//set monitoring period to 60 seconds
|
||||||
int monitorPeriod = MONITOR_PERIOD;
|
int monitorPeriod = MONITOR_PERIOD;
|
||||||
utils::CGroupConfigurator cg;
|
utils::CGroupConfigurator cg;
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
@ -87,12 +88,11 @@ void memoryMonitor()
|
|||||||
//get memory stats
|
//get memory stats
|
||||||
totalMem = cg.getTotalMemory();
|
totalMem = cg.getTotalMemory();
|
||||||
uint64_t freeMem = cg.getFreeMemory();
|
uint64_t freeMem = cg.getFreeMemory();
|
||||||
uint64_t usedMem = totalMem - freeMem;
|
uint64_t usedMem = totalMem - freeMem;
|
||||||
|
|
||||||
//get swap stats
|
//get swap stats
|
||||||
uint64_t totalSwap = cg.getTotalSwapSpace();
|
uint64_t totalSwap = cg.getTotalSwapSpace();
|
||||||
uint64_t usedSwap = cg.getSwapInUse();
|
uint64_t usedSwap = cg.getSwapInUse();
|
||||||
|
|
||||||
|
|
||||||
if ( totalSwap == 0 ) {
|
if ( totalSwap == 0 ) {
|
||||||
swapUsagePercent = 0;
|
swapUsagePercent = 0;
|
||||||
@ -136,13 +136,34 @@ void memoryMonitor()
|
|||||||
else
|
else
|
||||||
memoryUsagePercent = (usedMem / (totalMem / 100)) + 1;
|
memoryUsagePercent = (usedMem / (totalMem / 100)) + 1;
|
||||||
|
|
||||||
|
/*LoggingID lid(SERVER_MONITOR_LOG_ID);
|
||||||
|
MessageLog ml(lid);
|
||||||
|
Message msg;
|
||||||
|
Message::Args args;
|
||||||
|
args.add("memoryUsagePercent ");
|
||||||
|
args.add((uint64_t) memoryUsagePercent);
|
||||||
|
args.add("usedMem ");
|
||||||
|
args.add((uint64_t) usedMem);
|
||||||
|
args.add("totalMem ");
|
||||||
|
args.add((uint64_t) totalMem);
|
||||||
|
msg.format(args);
|
||||||
|
ml.logInfoMessage(msg);
|
||||||
|
*/
|
||||||
|
//first time called, log
|
||||||
|
//adjust if over 100%
|
||||||
|
if ( swapUsagePercent < 0 )
|
||||||
|
swapUsagePercent = 0;
|
||||||
|
if ( swapUsagePercent > 100 )
|
||||||
|
swapUsagePercent = 100;
|
||||||
|
|
||||||
|
if ( memoryUsagePercent < 0 )
|
||||||
|
memoryUsagePercent = 0;
|
||||||
|
if ( memoryUsagePercent > 100 )
|
||||||
|
memoryUsagePercent = 100;
|
||||||
|
|
||||||
// check for Memory alarms
|
// check for Memory alarms
|
||||||
if (memoryUsagePercent >= memoryCritical && memoryCritical > 0 ) {
|
if (memoryUsagePercent >= memoryCritical && memoryCritical > 0 ) {
|
||||||
if ( monitorPeriod == MONITOR_PERIOD ) {
|
if ( monitorPeriod == MONITOR_PERIOD ) {
|
||||||
//first time called, log
|
|
||||||
//adjust if over 100%
|
|
||||||
if ( memoryUsagePercent > 100 )
|
|
||||||
memoryUsagePercent = 100;
|
|
||||||
|
|
||||||
LoggingID lid(SERVER_MONITOR_LOG_ID);
|
LoggingID lid(SERVER_MONITOR_LOG_ID);
|
||||||
MessageLog ml(lid);
|
MessageLog ml(lid);
|
||||||
|
@ -3783,7 +3783,6 @@ void ProcessManager::setSystemState(uint16_t state)
|
|||||||
{
|
{
|
||||||
// log.writeLog(__LINE__, "EXCEPTION ERROR on MessageQueueClient: Caught unknown exception!", LOG_TYPE_ERROR);
|
// log.writeLog(__LINE__, "EXCEPTION ERROR on MessageQueueClient: Caught unknown exception!", LOG_TYPE_ERROR);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&STATUS_LOCK);
|
|
||||||
|
|
||||||
// Process Alarms
|
// Process Alarms
|
||||||
string system = "System";
|
string system = "System";
|
||||||
@ -3798,7 +3797,11 @@ void ProcessManager::setSystemState(uint16_t state)
|
|||||||
else
|
else
|
||||||
if ( state == oam::AUTO_OFFLINE )
|
if ( state == oam::AUTO_OFFLINE )
|
||||||
aManager.sendAlarmReport(system.c_str(), SYSTEM_DOWN_AUTO, SET);
|
aManager.sendAlarmReport(system.c_str(), SYSTEM_DOWN_AUTO, SET);
|
||||||
|
//this alarm doesnt get clear by reporter, so clear on stopage
|
||||||
|
aManager.sendAlarmReport(system.c_str(), CONN_FAILURE, CLEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&STATUS_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************************
|
/******************************************************************************************
|
||||||
|
@ -173,9 +173,6 @@ uint64_t CGroupConfigurator::getTotalMemory()
|
|||||||
{
|
{
|
||||||
uint64_t ret;
|
uint64_t ret;
|
||||||
|
|
||||||
if (totalMemory != 0)
|
|
||||||
return totalMemory;
|
|
||||||
|
|
||||||
if (!cGroupDefined)
|
if (!cGroupDefined)
|
||||||
ret = getTotalMemoryFromProc();
|
ret = getTotalMemoryFromProc();
|
||||||
else {
|
else {
|
||||||
@ -183,7 +180,11 @@ uint64_t CGroupConfigurator::getTotalMemory()
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = getTotalMemoryFromProc();
|
ret = getTotalMemoryFromProc();
|
||||||
}
|
}
|
||||||
//cout << "Total mem available is " << ret << endl;
|
//ostringstream os;
|
||||||
|
//os << "Total mem available is " << ret;
|
||||||
|
//cerr << os.str() << endl;
|
||||||
|
//log(logging::LOG_TYPE_WARNING, os.str());
|
||||||
|
|
||||||
totalMemory = ret;
|
totalMemory = ret;
|
||||||
return totalMemory;
|
return totalMemory;
|
||||||
}
|
}
|
||||||
@ -216,17 +217,31 @@ uint64_t CGroupConfigurator::getTotalMemoryFromProc()
|
|||||||
input[79] = '\0';
|
input[79] = '\0';
|
||||||
pclose(cmdPipe);
|
pclose(cmdPipe);
|
||||||
memTot = atoi(input);
|
memTot = atoi(input);
|
||||||
|
|
||||||
|
//ostringstream os;
|
||||||
|
//os << "FreeBSD Total mem available is " << memTot;
|
||||||
|
//cerr << os.str() << endl;
|
||||||
|
//log(logging::LOG_TYPE_WARNING, os.str());
|
||||||
#else
|
#else
|
||||||
ifstream in("/proc/meminfo");
|
ifstream in("/proc/meminfo");
|
||||||
string x;
|
string x;
|
||||||
|
|
||||||
in >> x;
|
in >> x;
|
||||||
in >> memTot;
|
in >> memTot;
|
||||||
|
|
||||||
|
//ostringstream os;
|
||||||
|
//os << "meminfo Total mem available is " << memTot;
|
||||||
|
//cerr << os.str() << endl;
|
||||||
|
//log(logging::LOG_TYPE_WARNING, os.str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//memTot is now in KB, convert to bytes
|
//memTot is now in KB, convert to bytes
|
||||||
memTot *= 1024;
|
memTot *= 1024;
|
||||||
|
|
||||||
|
//os << "meminfo Total bytes mem available is " << memTot;
|
||||||
|
//cerr << os.str() << endl;
|
||||||
|
//log(logging::LOG_TYPE_WARNING, os.str());
|
||||||
|
|
||||||
return memTot;
|
return memTot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,9 +322,8 @@ uint64_t CGroupConfigurator::getMemUsageFromCGroup()
|
|||||||
uint64_t CGroupConfigurator::getFreeMemoryFromProc()
|
uint64_t CGroupConfigurator::getFreeMemoryFromProc()
|
||||||
{
|
{
|
||||||
uint64_t memFree = 0;
|
uint64_t memFree = 0;
|
||||||
uint64_t buffers = 0;
|
uint64_t memAvailable = 0;
|
||||||
uint64_t cached = 0;
|
uint64_t memTotal = 0;
|
||||||
uint64_t memTotal = 0;
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
MEMORYSTATUSEX memStat;
|
MEMORYSTATUSEX memStat;
|
||||||
@ -338,18 +352,15 @@ uint64_t CGroupConfigurator::getFreeMemoryFromProc()
|
|||||||
in >> memFree;
|
in >> memFree;
|
||||||
in >> x; // kB
|
in >> x; // kB
|
||||||
|
|
||||||
in >> x; // Buffers:
|
in >> x; // MemAvailable:
|
||||||
in >> buffers;
|
in >> memAvailable;
|
||||||
in >> x; // kB
|
in >> x; // kB
|
||||||
|
|
||||||
in >> x; // Cached:
|
|
||||||
in >> cached;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// amount available for application
|
// amount available for application
|
||||||
memFree = memFree + buffers + cached;
|
memAvailable *= 1024;
|
||||||
memFree *= 1024;
|
return memAvailable;
|
||||||
return memFree;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t CGroupConfigurator::getTotalSwapSpace()
|
uint64_t CGroupConfigurator::getTotalSwapSpace()
|
||||||
|
Reference in New Issue
Block a user