1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-5555 Add support for startreadonly command.

This patch adds support for `startreadonly` command which waits
until all active cpimport jobs are done and then puts controller node to readonly
mode.
This commit is contained in:
Denis Khalikov
2023-10-02 23:46:53 +03:00
committed by Leonid Fedorov
parent 2b20e1de25
commit 3fcb9b66f5
11 changed files with 403 additions and 18 deletions

View File

@ -34,6 +34,7 @@
#include <string>
#include <stdexcept>
#include <limits>
#include <unordered_set>
using namespace std;
#include <boost/thread/mutex.hpp>
@ -256,6 +257,28 @@ const QueryContext SessionManagerServer::sysCatVerID()
return ret;
}
uint32_t SessionManagerServer::newCpimportJob()
{
std::scoped_lock lk(cpimportMutex);
activeCpimportJobs.insert(cpimportJobId);
auto ret = cpimportJobId;
++cpimportJobId;
return ret;
}
void SessionManagerServer::finishCpimortJob(uint32_t jobId)
{
std::scoped_lock lk(cpimportMutex);
if (activeCpimportJobs.count(jobId))
activeCpimportJobs.erase(jobId);
}
void SessionManagerServer::clearAllCpimportJobs()
{
std::scoped_lock lk(cpimportMutex);
activeCpimportJobs.clear();
}
const TxnID SessionManagerServer::newTxnID(const SID session, bool block, bool isDDL)
{
TxnID ret; // ctor must set valid = false
@ -383,6 +406,12 @@ void SessionManagerServer::clearSystemState(uint32_t state)
saveSystemState();
}
uint32_t SessionManagerServer::getCpimportJobsCount()
{
std::scoped_lock lk(cpimportMutex);
return activeCpimportJobs.size();
}
uint32_t SessionManagerServer::getTxnCount()
{
boost::mutex::scoped_lock lk(mutex);