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
clang format apply
This commit is contained in:
@ -44,17 +44,16 @@
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable : 4200)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4200)
|
||||
#endif
|
||||
|
||||
namespace BRM
|
||||
{
|
||||
|
||||
/** @brief Issues transaction IDs and keeps track of the current system-wide version ID.
|
||||
*
|
||||
* This class's primary purpose is to keep track of the current system-wide version ID and issue transaction IDs.
|
||||
* It can be used simultaneously by multiple threads and processes.
|
||||
* This class's primary purpose is to keep track of the current system-wide version ID and issue transaction
|
||||
* IDs. It can be used simultaneously by multiple threads and processes.
|
||||
*
|
||||
* It uses system-wide semaphores and shared memory segments for IPC.
|
||||
* It allocates both if they don't already exist, but it only deallocates
|
||||
@ -91,204 +90,207 @@ namespace BRM
|
||||
|
||||
class SessionManagerServer
|
||||
{
|
||||
public:
|
||||
/** @brief SID = Session ID */
|
||||
typedef uint32_t SID;
|
||||
public:
|
||||
/** @brief SID = Session ID */
|
||||
typedef uint32_t SID;
|
||||
|
||||
// State flags. These bit values are stored in Overlay::state and reflect the current state of the system
|
||||
static const uint32_t SS_READY; /// bit 0 => Set by dmlProc one time when dmlProc is ready
|
||||
static const uint32_t SS_SUSPENDED; /// bit 1 => Set by console when the system has been suspended by user.
|
||||
static const uint32_t SS_SUSPEND_PENDING; /// bit 2 => Set by console when user wants to suspend, but writing is occuring.
|
||||
static const uint32_t SS_SHUTDOWN_PENDING; /// bit 3 => Set by console when user wants to shutdown, but writing is occuring.
|
||||
static const uint32_t SS_ROLLBACK; /// bit 4 => In combination with a PENDING flag, force a rollback as soom as possible.
|
||||
static const uint32_t SS_FORCE; /// bit 5 => In combination with a PENDING flag, force a shutdown without rollback.
|
||||
static const uint32_t SS_QUERY_READY; /// bit 6 => Set by ProcManager when system is ready for queries
|
||||
// State flags. These bit values are stored in Overlay::state and reflect the current state of the system
|
||||
static const uint32_t SS_READY; /// bit 0 => Set by dmlProc one time when dmlProc is ready
|
||||
static const uint32_t SS_SUSPENDED; /// bit 1 => Set by console when the system has been suspended by user.
|
||||
static const uint32_t
|
||||
SS_SUSPEND_PENDING; /// bit 2 => Set by console when user wants to suspend, but writing is occuring.
|
||||
static const uint32_t
|
||||
SS_SHUTDOWN_PENDING; /// bit 3 => Set by console when user wants to shutdown, but writing is occuring.
|
||||
static const uint32_t
|
||||
SS_ROLLBACK; /// bit 4 => In combination with a PENDING flag, force a rollback as soom as possible.
|
||||
static const uint32_t
|
||||
SS_FORCE; /// bit 5 => In combination with a PENDING flag, force a shutdown without rollback.
|
||||
static const uint32_t SS_QUERY_READY; /// bit 6 => Set by ProcManager when system is ready for queries
|
||||
|
||||
/** @brief Constructor
|
||||
*
|
||||
* This sets up the shared memory segment & semaphores used by this
|
||||
* instance. No additional set-up calls are necessary.
|
||||
* @note throws ios_base::failure on file IO error, runtime_error for
|
||||
* other types of errors. It might be worthwhile to define additional
|
||||
* exceptions for all the different types of failures that can happen
|
||||
* here.
|
||||
*/
|
||||
EXPORT SessionManagerServer();
|
||||
/** @brief Constructor
|
||||
*
|
||||
* This sets up the shared memory segment & semaphores used by this
|
||||
* instance. No additional set-up calls are necessary.
|
||||
* @note throws ios_base::failure on file IO error, runtime_error for
|
||||
* other types of errors. It might be worthwhile to define additional
|
||||
* exceptions for all the different types of failures that can happen
|
||||
* here.
|
||||
*/
|
||||
EXPORT SessionManagerServer();
|
||||
|
||||
/** @brief Destructor
|
||||
*
|
||||
* This detaches the shared memory segment. If DESTROYSHMSEG is defined and this
|
||||
* is the last reference to it, it will be saved to disk and destroyed.
|
||||
* It does not destroy the semaphores. Those persist until the system
|
||||
* is shut down.
|
||||
*/
|
||||
virtual ~SessionManagerServer();
|
||||
/** @brief Destructor
|
||||
*
|
||||
* This detaches the shared memory segment. If DESTROYSHMSEG is defined and this
|
||||
* is the last reference to it, it will be saved to disk and destroyed.
|
||||
* It does not destroy the semaphores. Those persist until the system
|
||||
* is shut down.
|
||||
*/
|
||||
virtual ~SessionManagerServer();
|
||||
|
||||
/** @brief Gets the current version ID
|
||||
*
|
||||
* Gets the current version ID.
|
||||
*/
|
||||
EXPORT const QueryContext verID();
|
||||
/** @brief Gets the current version ID
|
||||
*
|
||||
* Gets the current version ID.
|
||||
*/
|
||||
EXPORT const QueryContext verID();
|
||||
|
||||
/** @brief Gets the current version ID
|
||||
*
|
||||
* Gets the current version ID.
|
||||
*/
|
||||
EXPORT const QueryContext sysCatVerID();
|
||||
/** @brief Gets the current version ID
|
||||
*
|
||||
* Gets the current version ID.
|
||||
*/
|
||||
EXPORT const QueryContext sysCatVerID();
|
||||
|
||||
/** @brief Gets a new Transaction ID
|
||||
*
|
||||
* Makes a new Transaction ID, associates it with the given session
|
||||
* and increments the system-wide version ID
|
||||
* @note This blocks until (# active transactions) \< MaxTxns unless block == false
|
||||
* @note Throws runtime_error on semaphore-related error
|
||||
* @note This will always return a valid TxnID unless block == false, in which case
|
||||
* it will return a valid TxnID iff it doesn't have to block.
|
||||
* @param session The session ID to associate with the transaction ID
|
||||
* @param block If true, this will block until there is an available slot, otherwise
|
||||
* it will return a TxnID marked invalid, signifying that it could not start a new transaction
|
||||
* @return The new transaction ID.
|
||||
*/
|
||||
EXPORT const TxnID newTxnID(const SID session, bool block = true, bool isDDL = false);
|
||||
/** @brief Gets a new Transaction ID
|
||||
*
|
||||
* Makes a new Transaction ID, associates it with the given session
|
||||
* and increments the system-wide version ID
|
||||
* @note This blocks until (# active transactions) \< MaxTxns unless block == false
|
||||
* @note Throws runtime_error on semaphore-related error
|
||||
* @note This will always return a valid TxnID unless block == false, in which case
|
||||
* it will return a valid TxnID iff it doesn't have to block.
|
||||
* @param session The session ID to associate with the transaction ID
|
||||
* @param block If true, this will block until there is an available slot, otherwise
|
||||
* it will return a TxnID marked invalid, signifying that it could not start a new transaction
|
||||
* @return The new transaction ID.
|
||||
*/
|
||||
EXPORT const TxnID newTxnID(const SID session, bool block = true, bool isDDL = false);
|
||||
|
||||
/** @brief Record that a transaction has been committed
|
||||
*
|
||||
* Record that a transaction has been committed.
|
||||
* @note Throws runtime_error on a semaphore-related error, invalid_argument
|
||||
* when txnid can't be found
|
||||
* @param txnid The committed transaction ID. This is marked invalid
|
||||
* on return.
|
||||
*/
|
||||
void committed(TxnID& txn)
|
||||
{
|
||||
finishTransaction(txn);
|
||||
}
|
||||
/** @brief Record that a transaction has been committed
|
||||
*
|
||||
* Record that a transaction has been committed.
|
||||
* @note Throws runtime_error on a semaphore-related error, invalid_argument
|
||||
* when txnid can't be found
|
||||
* @param txnid The committed transaction ID. This is marked invalid
|
||||
* on return.
|
||||
*/
|
||||
void committed(TxnID& txn)
|
||||
{
|
||||
finishTransaction(txn);
|
||||
}
|
||||
|
||||
/** @brief Record that a transaction has been rolled back
|
||||
*
|
||||
* Record that a transaction has been rolled back.
|
||||
* @note Throws runtime_error on a semaphore-related error, invalid_argument
|
||||
* when txnid can't be found
|
||||
* @param txnid The rolled back transaction ID. This is marked invalid
|
||||
* on return.
|
||||
*/
|
||||
void rolledback(TxnID& txn)
|
||||
{
|
||||
finishTransaction(txn);
|
||||
}
|
||||
/** @brief Record that a transaction has been rolled back
|
||||
*
|
||||
* Record that a transaction has been rolled back.
|
||||
* @note Throws runtime_error on a semaphore-related error, invalid_argument
|
||||
* when txnid can't be found
|
||||
* @param txnid The rolled back transaction ID. This is marked invalid
|
||||
* on return.
|
||||
*/
|
||||
void rolledback(TxnID& txn)
|
||||
{
|
||||
finishTransaction(txn);
|
||||
}
|
||||
|
||||
/** @brief Gets the transaction ID associated with a given session ID
|
||||
*
|
||||
* Gets the transaction ID associated with a given session ID.
|
||||
* @note Throws runtime_error on a semaphore-related error
|
||||
* @param session The session ID
|
||||
* @return A valid transaction ID if there's an association; an invalid
|
||||
* one if there isn't.
|
||||
*/
|
||||
EXPORT const TxnID getTxnID(const SID session);
|
||||
/** @brief Gets the transaction ID associated with a given session ID
|
||||
*
|
||||
* Gets the transaction ID associated with a given session ID.
|
||||
* @note Throws runtime_error on a semaphore-related error
|
||||
* @param session The session ID
|
||||
* @return A valid transaction ID if there's an association; an invalid
|
||||
* one if there isn't.
|
||||
*/
|
||||
EXPORT const TxnID getTxnID(const SID session);
|
||||
|
||||
/** @brief Gets an array containing all active SID-TID associations
|
||||
*
|
||||
* Gets an array containing the SID-TID associations of all active
|
||||
* transactions. This is intended to be used by another object
|
||||
* that can determine which sessions are still live and which
|
||||
* transactions need to go away.
|
||||
* @note Throws runtime_error on a semaphore-related error
|
||||
* @param len (out) the length of the array
|
||||
* @return A pointer to the array. Note: The caller is responsible for
|
||||
* deallocating it. Use delete[].
|
||||
*/
|
||||
EXPORT boost::shared_array<SIDTIDEntry> SIDTIDMap(int& len);
|
||||
/** @brief Gets an array containing all active SID-TID associations
|
||||
*
|
||||
* Gets an array containing the SID-TID associations of all active
|
||||
* transactions. This is intended to be used by another object
|
||||
* that can determine which sessions are still live and which
|
||||
* transactions need to go away.
|
||||
* @note Throws runtime_error on a semaphore-related error
|
||||
* @param len (out) the length of the array
|
||||
* @return A pointer to the array. Note: The caller is responsible for
|
||||
* deallocating it. Use delete[].
|
||||
*/
|
||||
EXPORT boost::shared_array<SIDTIDEntry> SIDTIDMap(int& len);
|
||||
|
||||
/**
|
||||
* get a unique 32-bit number
|
||||
*/
|
||||
uint32_t getUnique32()
|
||||
{
|
||||
return atomicops::atomicInc(&unique32);
|
||||
}
|
||||
/**
|
||||
* get a unique 32-bit number
|
||||
*/
|
||||
uint32_t getUnique32()
|
||||
{
|
||||
return atomicops::atomicInc(&unique32);
|
||||
}
|
||||
|
||||
/**
|
||||
* get a unique 64-bit number
|
||||
*/
|
||||
uint64_t getUnique64()
|
||||
{
|
||||
return atomicops::atomicInc(&unique64);
|
||||
}
|
||||
/**
|
||||
* get a unique 64-bit number
|
||||
*/
|
||||
uint64_t getUnique64()
|
||||
{
|
||||
return atomicops::atomicInc(&unique64);
|
||||
}
|
||||
|
||||
/** @brief Resets the semaphores to their original state. For testing only.
|
||||
*
|
||||
* Resets the semaphores to their original state. For testing only.
|
||||
*/
|
||||
EXPORT void reset();
|
||||
/** @brief Resets the semaphores to their original state. For testing only.
|
||||
*
|
||||
* Resets the semaphores to their original state. For testing only.
|
||||
*/
|
||||
EXPORT void reset();
|
||||
|
||||
/**
|
||||
* get the Txn ID filename
|
||||
*/
|
||||
std::string getTxnIDFilename() const
|
||||
{
|
||||
return txnidFilename;
|
||||
}
|
||||
/**
|
||||
* get the Txn ID filename
|
||||
*/
|
||||
std::string getTxnIDFilename() const
|
||||
{
|
||||
return txnidFilename;
|
||||
}
|
||||
|
||||
/** @brief set system state info
|
||||
*
|
||||
* Sets the bits on in Overlay::systemState that are found on in
|
||||
* state. That is Overlay::systemState | state.
|
||||
*/
|
||||
EXPORT void setSystemState(uint32_t state);
|
||||
/** @brief set system state info
|
||||
*
|
||||
* Sets the bits on in Overlay::systemState that are found on in
|
||||
* state. That is Overlay::systemState | state.
|
||||
*/
|
||||
EXPORT void setSystemState(uint32_t state);
|
||||
|
||||
/** @brief set system state info
|
||||
*
|
||||
* Clears the bits on in Overlay::systemState that are found on
|
||||
* in state. That is Overlay::systemState & ~state.
|
||||
*/
|
||||
EXPORT void clearSystemState(uint32_t state);
|
||||
/** @brief set system state info
|
||||
*
|
||||
* Clears the bits on in Overlay::systemState that are found on
|
||||
* in state. That is Overlay::systemState & ~state.
|
||||
*/
|
||||
EXPORT void clearSystemState(uint32_t state);
|
||||
|
||||
/** @brief get system state info
|
||||
*
|
||||
* Returns the Overlay::systemState flags
|
||||
*/
|
||||
void getSystemState(uint32_t& state)
|
||||
{
|
||||
state = systemState;
|
||||
}
|
||||
/** @brief get system state info
|
||||
*
|
||||
* Returns the Overlay::systemState flags
|
||||
*/
|
||||
void getSystemState(uint32_t& state)
|
||||
{
|
||||
state = systemState;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the number of active txn's
|
||||
*/
|
||||
EXPORT uint32_t getTxnCount();
|
||||
/**
|
||||
* get the number of active txn's
|
||||
*/
|
||||
EXPORT uint32_t getTxnCount();
|
||||
|
||||
private:
|
||||
SessionManagerServer(const SessionManagerServer&);
|
||||
SessionManagerServer& operator=(const SessionManagerServer&);
|
||||
private:
|
||||
SessionManagerServer(const SessionManagerServer&);
|
||||
SessionManagerServer& operator=(const SessionManagerServer&);
|
||||
|
||||
void loadState();
|
||||
void saveSystemState();
|
||||
void finishTransaction(TxnID& txn);
|
||||
void saveSMTxnIDAndState();
|
||||
void loadState();
|
||||
void saveSystemState();
|
||||
void finishTransaction(TxnID& txn);
|
||||
void saveSMTxnIDAndState();
|
||||
|
||||
volatile uint32_t unique32;
|
||||
volatile uint64_t unique64;
|
||||
volatile uint32_t unique32;
|
||||
volatile uint64_t unique64;
|
||||
|
||||
int maxTxns; // the maximum number of concurrent transactions
|
||||
std::string txnidFilename;
|
||||
execplan::CalpontSystemCatalog::SCN _verID;
|
||||
execplan::CalpontSystemCatalog::SCN _sysCatVerID;
|
||||
uint32_t systemState;
|
||||
int maxTxns; // the maximum number of concurrent transactions
|
||||
std::string txnidFilename;
|
||||
execplan::CalpontSystemCatalog::SCN _verID;
|
||||
execplan::CalpontSystemCatalog::SCN _sysCatVerID;
|
||||
uint32_t systemState;
|
||||
|
||||
std::map<SID, execplan::CalpontSystemCatalog::SCN> activeTxns;
|
||||
typedef std::map<SID, execplan::CalpontSystemCatalog::SCN>::iterator iterator;
|
||||
std::map<SID, execplan::CalpontSystemCatalog::SCN> activeTxns;
|
||||
typedef std::map<SID, execplan::CalpontSystemCatalog::SCN>::iterator iterator;
|
||||
|
||||
boost::mutex mutex;
|
||||
boost::condition_variable condvar; // used to synthesize a semaphore
|
||||
uint32_t semValue;
|
||||
boost::mutex mutex;
|
||||
boost::condition_variable condvar; // used to synthesize a semaphore
|
||||
uint32_t semValue;
|
||||
};
|
||||
|
||||
} //namespace
|
||||
} // namespace BRM
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (pop)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
Reference in New Issue
Block a user