You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-5464: Fixes of bugs from ASAN warnings, part one (#2792)
* Fixes of bugs from ASAN warnings, part one * MQC as static library, with nifty counter for global map and mutex * Switch clang to 16 * link messageqcpp to execplan
This commit is contained in:
@ -27,6 +27,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
|
||||
#include "messagequeue.h"
|
||||
#include "bytestream.h"
|
||||
@ -57,21 +58,18 @@ void timespec_sub(const struct timespec& tv1, const struct timespec& tv2, double
|
||||
|
||||
namespace BRM
|
||||
{
|
||||
SlaveComm::SlaveComm(string hostname, SlaveDBRMNode* s)
|
||||
: slave(s)
|
||||
, currentSaveFile(NULL)
|
||||
, journalh(NULL)
|
||||
SlaveComm::SlaveComm(string hostname)
|
||||
{
|
||||
config::Config* config = config::Config::makeConfig();
|
||||
string tmp;
|
||||
|
||||
slave = std::make_unique<SlaveDBRMNode>();
|
||||
bool tellUser = true;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
try
|
||||
{
|
||||
server = new MessageQueueServer(hostname);
|
||||
server = std::make_unique<MessageQueueServer>(hostname);
|
||||
break;
|
||||
}
|
||||
catch (runtime_error& re)
|
||||
@ -133,8 +131,8 @@ SlaveComm::SlaveComm(string hostname, SlaveDBRMNode* s)
|
||||
journalName = savefile + "_journal";
|
||||
const char* filename = journalName.c_str();
|
||||
|
||||
journalh = IDBDataFile::open(IDBPolicy::getType(filename, IDBPolicy::WRITEENG), filename, "a", 0);
|
||||
if (journalh == NULL)
|
||||
journalh.reset(IDBDataFile::open(IDBPolicy::getType(filename, IDBPolicy::WRITEENG), filename, "a", 0));
|
||||
if (journalh == nullptr)
|
||||
throw runtime_error("Could not open the BRM journal for writing!");
|
||||
}
|
||||
else
|
||||
@ -162,8 +160,6 @@ SlaveComm::SlaveComm(string hostname, SlaveDBRMNode* s)
|
||||
}
|
||||
|
||||
SlaveComm::SlaveComm()
|
||||
: currentSaveFile(NULL)
|
||||
, journalh(NULL)
|
||||
{
|
||||
config::Config* config = config::Config::makeConfig();
|
||||
|
||||
@ -192,23 +188,9 @@ SlaveComm::SlaveComm()
|
||||
server = NULL;
|
||||
standalone = true;
|
||||
printOnly = false;
|
||||
slave = new SlaveDBRMNode();
|
||||
slave = std::make_unique<SlaveDBRMNode>();
|
||||
}
|
||||
|
||||
SlaveComm::~SlaveComm()
|
||||
{
|
||||
delete server;
|
||||
server = NULL;
|
||||
|
||||
if (firstSlave)
|
||||
{
|
||||
delete currentSaveFile;
|
||||
currentSaveFile = NULL;
|
||||
}
|
||||
|
||||
delete journalh;
|
||||
journalh = NULL;
|
||||
}
|
||||
|
||||
void SlaveComm::stop()
|
||||
{
|
||||
@ -1946,8 +1928,7 @@ void SlaveComm::do_confirm()
|
||||
{
|
||||
if (!currentSaveFile)
|
||||
{
|
||||
currentSaveFile =
|
||||
IDBDataFile::open(IDBPolicy::getType(tmp.c_str(), IDBPolicy::WRITEENG), tmp.c_str(), "wb", 0);
|
||||
currentSaveFile.reset(IDBDataFile::open(IDBPolicy::getType(tmp.c_str(), IDBPolicy::WRITEENG), tmp.c_str(), "wb", 0));
|
||||
}
|
||||
|
||||
if (currentSaveFile == NULL)
|
||||
@ -1970,7 +1951,7 @@ void SlaveComm::do_confirm()
|
||||
if (err < (int)relative.length())
|
||||
{
|
||||
ostringstream os;
|
||||
os << "WorkerComm: currentfile write() returned " << err << " file pointer is " << currentSaveFile;
|
||||
os << "WorkerComm: currentfile write() returned " << err << " file pointer is " << currentSaveFile.get();
|
||||
|
||||
if (err < 0)
|
||||
os << " errno: " << strerror(errno);
|
||||
@ -1979,13 +1960,13 @@ void SlaveComm::do_confirm()
|
||||
}
|
||||
|
||||
currentSaveFile->flush();
|
||||
delete currentSaveFile;
|
||||
currentSaveFile = NULL;
|
||||
|
||||
currentSaveFile = nullptr;
|
||||
saveFileToggle = !saveFileToggle;
|
||||
|
||||
delete journalh;
|
||||
journalh = IDBDataFile::open(IDBPolicy::getType(journalName.c_str(), IDBPolicy::WRITEENG),
|
||||
journalName.c_str(), "w+b", 0);
|
||||
;
|
||||
journalh.reset(IDBDataFile::open(IDBPolicy::getType(journalName.c_str(), IDBPolicy::WRITEENG),
|
||||
journalName.c_str(), "w+b", 0));
|
||||
|
||||
if (!journalh)
|
||||
throw runtime_error("Could not open the BRM journal for writing!");
|
||||
@ -2245,7 +2226,6 @@ void SlaveComm::do_ownerCheck(ByteStream& msg)
|
||||
master.write(reply);
|
||||
}
|
||||
|
||||
// FIXME: needs to be refactored along with SessionManagerServer::lookupProcessStatus()
|
||||
bool SlaveComm::processExists(const uint32_t pid, const string& pname)
|
||||
{
|
||||
string stat;
|
||||
@ -2278,7 +2258,6 @@ bool SlaveComm::processExists(const uint32_t pid, const string& pname)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SlaveComm::do_dmlLockLBIDRanges(ByteStream& msg)
|
||||
{
|
||||
ByteStream reply;
|
||||
|
@ -54,8 +54,10 @@ class SlaveComm
|
||||
EXPORT SlaveComm();
|
||||
|
||||
/** Use this ctor to have it connected to the rest of the DBRM system */
|
||||
EXPORT SlaveComm(std::string hostname, SlaveDBRMNode* s); // hostname = 'DBRM_WorkerN'
|
||||
EXPORT ~SlaveComm();
|
||||
EXPORT SlaveComm(std::string hostname); // hostname = 'DBRM_WorkerN'
|
||||
EXPORT ~SlaveComm() {};
|
||||
|
||||
SlaveDBRMNode& getSlaveNode() { return *slave; }
|
||||
|
||||
EXPORT void run();
|
||||
EXPORT void stop();
|
||||
@ -112,15 +114,15 @@ class SlaveComm
|
||||
void saveDelta();
|
||||
bool processExists(const uint32_t pid, const std::string& pname);
|
||||
|
||||
messageqcpp::MessageQueueServer* server;
|
||||
std::unique_ptr<messageqcpp::MessageQueueServer> server;
|
||||
messageqcpp::IOSocket master;
|
||||
SlaveDBRMNode* slave;
|
||||
std::unique_ptr<SlaveDBRMNode> slave;
|
||||
std::string savefile;
|
||||
bool release, die, firstSlave, saveFileToggle, takeSnapshot, doSaveDelta, standalone, printOnly;
|
||||
messageqcpp::ByteStream delta;
|
||||
idbdatafile::IDBDataFile* currentSaveFile;
|
||||
std::unique_ptr<idbdatafile::IDBDataFile> currentSaveFile;
|
||||
std::string journalName;
|
||||
idbdatafile::IDBDataFile* journalh;
|
||||
std::unique_ptr<idbdatafile::IDBDataFile> journalh;
|
||||
int64_t snapshotInterval, journalCount;
|
||||
struct timespec MSG_TIMEOUT;
|
||||
};
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <clocale>
|
||||
#include "slavedbrmnode.h"
|
||||
@ -39,7 +40,7 @@
|
||||
using namespace BRM;
|
||||
using namespace std;
|
||||
|
||||
SlaveComm* comm;
|
||||
std::unique_ptr<SlaveComm> comm;
|
||||
bool die = false;
|
||||
boost::thread_group monitorThreads;
|
||||
|
||||
@ -120,12 +121,11 @@ int ServiceWorkerNode::Child()
|
||||
{
|
||||
setupChildSignalHandlers();
|
||||
|
||||
SlaveDBRMNode slave;
|
||||
ShmKeys keys;
|
||||
|
||||
try
|
||||
{
|
||||
comm = new SlaveComm(std::string(m_nodename), &slave);
|
||||
comm = std::make_unique<SlaveComm>(std::string(m_nodename));
|
||||
NotifyServiceStarted();
|
||||
}
|
||||
catch (exception& e)
|
||||
@ -139,12 +139,12 @@ int ServiceWorkerNode::Child()
|
||||
}
|
||||
|
||||
/* Start 4 threads to monitor write lock state */
|
||||
monitorThreads.create_thread(RWLockMonitor(&die, slave.getEMFLLockStatus(), keys.KEYRANGE_EMFREELIST_BASE));
|
||||
monitorThreads.create_thread(RWLockMonitor(&die, slave.getEMLockStatus(), keys.KEYRANGE_EXTENTMAP_BASE));
|
||||
monitorThreads.create_thread(RWLockMonitor(&die, slave.getVBBMLockStatus(), keys.KEYRANGE_VBBM_BASE));
|
||||
monitorThreads.create_thread(RWLockMonitor(&die, slave.getVSSLockStatus(), keys.KEYRANGE_VSS_BASE));
|
||||
monitorThreads.create_thread(RWLockMonitor(&die, comm->getSlaveNode().getEMFLLockStatus(), keys.KEYRANGE_EMFREELIST_BASE));
|
||||
monitorThreads.create_thread(RWLockMonitor(&die, comm->getSlaveNode().getEMLockStatus(), keys.KEYRANGE_EXTENTMAP_BASE));
|
||||
monitorThreads.create_thread(RWLockMonitor(&die, comm->getSlaveNode().getVBBMLockStatus(), keys.KEYRANGE_VBBM_BASE));
|
||||
monitorThreads.create_thread(RWLockMonitor(&die, comm->getSlaveNode().getVSSLockStatus(), keys.KEYRANGE_VSS_BASE));
|
||||
monitorThreads.create_thread(
|
||||
RWLockMonitor(&die, slave.getEMIndexLockStatus(), keys.KEYRANGE_EXTENTMAP_INDEX_BASE));
|
||||
RWLockMonitor(&die, comm->getSlaveNode().getEMIndexLockStatus(), keys.KEYRANGE_EXTENTMAP_INDEX_BASE));
|
||||
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user