1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-27 21:01:50 +03:00

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

View File

@ -33,15 +33,16 @@ using namespace std;
using namespace rwlock;
using namespace logging;
namespace BRM {
RWLockMonitor::RWLockMonitor(const bool *d, const bool *ls, const uint32_t k) :
die(d), lockStatus(ls), key(k)
namespace BRM
{
ts.tv_sec = 210; // 3:30 timer
ts.tv_nsec = 0;
secsBetweenAttempts = 30;
lock.reset(new RWLock(key));
RWLockMonitor::RWLockMonitor(const bool* d, const bool* ls, const uint32_t k) :
die(d), lockStatus(ls), key(k)
{
ts.tv_sec = 210; // 3:30 timer
ts.tv_nsec = 0;
secsBetweenAttempts = 30;
lock.reset(new RWLock(key));
}
RWLockMonitor::~RWLockMonitor()
@ -51,89 +52,105 @@ RWLockMonitor::~RWLockMonitor()
void RWLockMonitor::operator()()
{
/*
* Grab a timed write lock.
* on failure
* if there's an active reader, do read_unlock()
* log everything else.
* *** write lock fixing is being postponed for now.
*/
/*
* Grab a timed write lock.
* on failure
* if there's an active reader, do read_unlock()
* log everything else.
* *** write lock fixing is being postponed for now.
*/
LockState state;
bool gotTheLock;
bool reportedProblem = false;
Logger logger(30);
LockState state;
bool gotTheLock;
bool reportedProblem = false;
Logger logger(30);
while (!(*die)) {
gotTheLock = lock->timed_write_lock(ts, &state);
if (*die)
break;
if (!gotTheLock) {
if (state.mutexLocked) {
if (!reportedProblem) {
//Message msg(ERR_BRM_MUTEX);
Message msg(M0092);
logger.logMessage(LOG_TYPE_CRITICAL, msg, LoggingID());
reportedProblem = true;
}
}
while (!(*die))
{
gotTheLock = lock->timed_write_lock(ts, &state);
else if (state.reading > 0) {
if (!reportedProblem) {
//Message msg(ERR_RECOVERABLE_LOCK_STATE);
Message msg(M0094);
Message::Args args;
if (*die)
break;
args.add(state.reading);
args.add(state.readerswaiting);
args.add(state.writing);
args.add(state.writerswaiting);
msg.format(args);
logger.logMessage(LOG_TYPE_WARNING, msg, LoggingID());
reportedProblem = true;
}
for (int i = 0; i < state.reading; i++)
lock->read_unlock();
}
if (!gotTheLock)
{
if (state.mutexLocked)
{
if (!reportedProblem)
{
//Message msg(ERR_BRM_MUTEX);
Message msg(M0092);
logger.logMessage(LOG_TYPE_CRITICAL, msg, LoggingID());
reportedProblem = true;
}
}
// the write lock is held but not by this process, not good.
// there's a slight race here between these two vars but it's miniscule,
// and the worst thing that happens is a false positive error msg.
else if (state.writing > 0 && !(*lockStatus)) {
if (!reportedProblem) {
//Message msg(ERR_UNRECOVERABLE_LOCK_STATE);
Message msg(M0093);
Message::Args args;
else if (state.reading > 0)
{
if (!reportedProblem)
{
//Message msg(ERR_RECOVERABLE_LOCK_STATE);
Message msg(M0094);
Message::Args args;
args.add(state.reading);
args.add(state.readerswaiting);
args.add(state.writing);
args.add(state.writerswaiting);
msg.format(args);
logger.logMessage(LOG_TYPE_CRITICAL, msg, LoggingID());
reportedProblem = true;
}
args.add(state.reading);
args.add(state.readerswaiting);
args.add(state.writing);
args.add(state.writerswaiting);
msg.format(args);
logger.logMessage(LOG_TYPE_WARNING, msg, LoggingID());
reportedProblem = true;
}
/* put write lock recovery code here */
}
else {
// the workernode is legitmately taking a long time
//cout << "holds the lock. " << " r=" << state.reading << " rwt=" << state.readerswaiting <<
// " w=" << state.writing << " wwt=" << state.writerswaiting << endl;
}
}
else {
/* got the write lock. If there was a problem before it's been fixed. */
lock->write_unlock();
if (reportedProblem) {
//Message msg(ERR_SUCCESSFUL_RECOVERY);
Message msg(M0095);
logger.logMessage(LOG_TYPE_WARNING, msg, LoggingID());
reportedProblem = false;
}
sleep(secsBetweenAttempts);
}
}
for (int i = 0; i < state.reading; i++)
lock->read_unlock();
}
// the write lock is held but not by this process, not good.
// there's a slight race here between these two vars but it's miniscule,
// and the worst thing that happens is a false positive error msg.
else if (state.writing > 0 && !(*lockStatus))
{
if (!reportedProblem)
{
//Message msg(ERR_UNRECOVERABLE_LOCK_STATE);
Message msg(M0093);
Message::Args args;
args.add(state.reading);
args.add(state.readerswaiting);
args.add(state.writing);
args.add(state.writerswaiting);
msg.format(args);
logger.logMessage(LOG_TYPE_CRITICAL, msg, LoggingID());
reportedProblem = true;
}
/* put write lock recovery code here */
}
else
{
// the workernode is legitmately taking a long time
//cout << "holds the lock. " << " r=" << state.reading << " rwt=" << state.readerswaiting <<
// " w=" << state.writing << " wwt=" << state.writerswaiting << endl;
}
}
else
{
/* got the write lock. If there was a problem before it's been fixed. */
lock->write_unlock();
if (reportedProblem)
{
//Message msg(ERR_SUCCESSFUL_RECOVERY);
Message msg(M0095);
logger.logMessage(LOG_TYPE_WARNING, msg, LoggingID());
reportedProblem = false;
}
sleep(secsBetweenAttempts);
}
}
}
} /* namespace BRM */