1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +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

@ -27,8 +27,9 @@
#pragma once
#include <map>
#include <condition_variable>
#include <unordered_set>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
@ -39,7 +40,6 @@
#define EXPORT
namespace BRM
{
/** @brief Issues transaction IDs and keeps track of the current system-wide version ID.
@ -146,6 +146,15 @@ class SessionManagerServer
*/
EXPORT const TxnID newTxnID(const SID session, bool block = true, bool isDDL = false);
// Adds a new job into `active` cpimport job list and return id of that job.
EXPORT uint32_t newCpimportJob();
// Removes the given `jobId` from `active` cpimort job list.
EXPORT void finishCpimortJob(uint32_t jobId);
// Clears all active cpimport jobs.
EXPORT void clearAllCpimportJobs();
/** @brief Record that a transaction has been committed
*
* Record that a transaction has been committed.
@ -253,6 +262,9 @@ class SessionManagerServer
*/
EXPORT uint32_t getTxnCount();
EXPORT uint32_t getCpimportJobsCount();
private:
SessionManagerServer(const SessionManagerServer&);
SessionManagerServer& operator=(const SessionManagerServer&);
@ -277,9 +289,12 @@ class SessionManagerServer
boost::mutex mutex;
boost::condition_variable condvar; // used to synthesize a semaphore
uint32_t semValue;
std::unordered_set<uint32_t> activeCpimportJobs;
uint32_t cpimportJobId{0};
std::mutex cpimportMutex;
};
} // namespace BRM
#undef EXPORT