MXS-2481 Handle sqlite3 oom error

This commit is contained in:
Johan Wikman
2019-05-24 10:32:21 +03:00
parent feae0cda17
commit 60d065473e

View File

@ -189,7 +189,23 @@ ClustrixMonitor* ClustrixMonitor::create(const string& name, const string& modul
sqlite3* pDb = open_or_create_db(path);
return new ClustrixMonitor(name, module, pDb);
ClustrixMonitor* pThis = nullptr;
if (pDb)
{
// Even if the creation/opening of the sqlite3 database fails, we will still
// get a valid database handle.
pThis = new ClustrixMonitor(name, module, pDb);
}
else
{
// The handle will be null, *only* if the opening fails due to a memory
// allocation error.
MXS_ALERT("sqlite3 memory allocation failed, the Clustrix monitor "
"cannot continue.");
}
return pThis;
}
bool ClustrixMonitor::configure(const MXS_CONFIG_PARAMETER* pParams)