You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
Reformat all code to coding standard
This commit is contained in:
@ -40,20 +40,22 @@ void BulkLoad::sleepMS(long ms)
|
||||
{
|
||||
struct timespec rm_ts;
|
||||
|
||||
rm_ts.tv_sec = ms/1000;
|
||||
rm_ts.tv_nsec = ms%1000 *1000000;
|
||||
rm_ts.tv_sec = ms / 1000;
|
||||
rm_ts.tv_nsec = ms % 1000 * 1000000;
|
||||
#ifdef _MSC_VER
|
||||
Sleep(ms);
|
||||
Sleep(ms);
|
||||
#else
|
||||
struct timespec abs_ts;
|
||||
|
||||
do
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while(nanosleep(&abs_ts,&rm_ts) < 0);
|
||||
#endif
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// This is the main entry point method for each Read thread.
|
||||
@ -64,7 +66,7 @@ void BulkLoad::read(int id)
|
||||
#ifdef PROFILE
|
||||
Stats::registerReadProfThread( );
|
||||
#endif
|
||||
// First get a table to work on.
|
||||
// First get a table to work on.
|
||||
// Acquire the read mutex
|
||||
// Iterate over the table list
|
||||
// if the table's status is new, set the locker = id
|
||||
@ -76,27 +78,30 @@ void BulkLoad::read(int id)
|
||||
//
|
||||
// LOOP to select and read the next table
|
||||
//
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
tableId = -1;
|
||||
#ifdef PROFILE
|
||||
Stats::startReadEvent(WE_STATS_WAIT_TO_SELECT_TBL);
|
||||
#endif
|
||||
if((tableId = lockTableForRead(id)) == -1)
|
||||
|
||||
if ((tableId = lockTableForRead(id)) == -1)
|
||||
{
|
||||
fLog.logMsg( "BulkLoad::ReadOperation No more tables "
|
||||
"available for processing. Read thread "
|
||||
+ Convertor::int2Str(id) + " exiting...",
|
||||
MSGLVL_INFO2);
|
||||
"available for processing. Read thread "
|
||||
+ Convertor::int2Str(id) + " exiting...",
|
||||
MSGLVL_INFO2);
|
||||
#ifdef PROFILE
|
||||
Stats::stopReadEvent(WE_STATS_WAIT_TO_SELECT_TBL);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef PROFILE
|
||||
Stats::stopReadEvent(WE_STATS_WAIT_TO_SELECT_TBL);
|
||||
#endif
|
||||
int rc = fTableInfo[tableId].readTableData( );
|
||||
|
||||
if (rc != NO_ERROR)
|
||||
{
|
||||
// Error occurred while reading the data, break out of loop.
|
||||
@ -116,6 +121,7 @@ void BulkLoad::read(int id)
|
||||
{
|
||||
// We are bailing out because another thread set bad job status
|
||||
ostringstream oss;
|
||||
|
||||
if (tableId != -1)
|
||||
oss << "Bulkload Read (thread " << id <<
|
||||
") Stopped reading Table " <<
|
||||
@ -123,12 +129,14 @@ void BulkLoad::read(int id)
|
||||
else
|
||||
oss << "Bulkload Read (thread " << id <<
|
||||
") Stopped reading Tables. " << ex.what();
|
||||
|
||||
fLog.logMsg( oss.str(), MSGLVL_INFO1 );
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
BulkStatus::setJobStatus( EXIT_FAILURE );
|
||||
ostringstream oss;
|
||||
|
||||
if (tableId != -1)
|
||||
oss << "Bulkload Read (thread " << id <<
|
||||
") Failed for Table " <<
|
||||
@ -138,13 +146,16 @@ void BulkLoad::read(int id)
|
||||
oss << "Bulkload Read (thread " << id <<
|
||||
") Failed for Table. " << ex.what() <<
|
||||
". Terminating this job.";
|
||||
if(tableId != -1) fTableInfo[tableId].fBRMReporter.addToErrMsgEntry(oss.str());
|
||||
fLog.logMsg( oss.str(), ERR_UNKNOWN, MSGLVL_CRITICAL );
|
||||
|
||||
if (tableId != -1) fTableInfo[tableId].fBRMReporter.addToErrMsgEntry(oss.str());
|
||||
|
||||
fLog.logMsg( oss.str(), ERR_UNKNOWN, MSGLVL_CRITICAL );
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BulkStatus::setJobStatus( EXIT_FAILURE );
|
||||
ostringstream oss;
|
||||
|
||||
if (tableId != -1)
|
||||
oss << "Bulkload Read (thread " << id <<
|
||||
") Failed for Table " <<
|
||||
@ -153,8 +164,10 @@ void BulkLoad::read(int id)
|
||||
else
|
||||
oss << "Bulkload Read (thread " << id <<
|
||||
") Failed for Table. Terminating this job.";
|
||||
if(tableId != -1) fTableInfo[tableId].fBRMReporter.addToErrMsgEntry(oss.str());
|
||||
fLog.logMsg( oss.str(), ERR_UNKNOWN, MSGLVL_CRITICAL );
|
||||
|
||||
if (tableId != -1) fTableInfo[tableId].fBRMReporter.addToErrMsgEntry(oss.str());
|
||||
|
||||
fLog.logMsg( oss.str(), ERR_UNKNOWN, MSGLVL_CRITICAL );
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,14 +180,14 @@ void BulkLoad::read(int id)
|
||||
int BulkLoad::lockTableForRead(int id)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(fReadMutex);
|
||||
|
||||
for(unsigned i=0; i<fTableInfo.size(); ++i)
|
||||
|
||||
for (unsigned i = 0; i < fTableInfo.size(); ++i)
|
||||
{
|
||||
if(fTableInfo[i].lockForRead(id))
|
||||
return i;
|
||||
if (fTableInfo[i].lockForRead(id))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -197,13 +210,13 @@ void BulkLoad::parse(int id)
|
||||
//
|
||||
// LOOP to parse BulkLoadBuffers as they're loaded by Read thread(s)
|
||||
//
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
#ifdef PROFILE
|
||||
Stats::startParseEvent(WE_STATS_WAIT_TO_SELECT_COL);
|
||||
#endif
|
||||
|
||||
// @bug 3271: Conditionally compile the thread deadlock debug logging
|
||||
// @bug 3271: Conditionally compile the thread deadlock debug logging
|
||||
#ifdef DEADLOCK_DEBUG
|
||||
// @bug2099+ Temporary hack.
|
||||
struct timeval tvStart;
|
||||
@ -219,7 +232,7 @@ void BulkLoad::parse(int id)
|
||||
// LOOP to wait and select table/column/buffers
|
||||
// (BulkLoadBuffers) as they are loaded by the Read buffer.
|
||||
//
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
tableId = -1;
|
||||
columnId = -1;
|
||||
@ -229,10 +242,10 @@ void BulkLoad::parse(int id)
|
||||
if (BulkStatus::getJobStatus() == EXIT_FAILURE)
|
||||
{
|
||||
throw SecondaryShutdownException( "BulkLoad::"
|
||||
"parse() responding to job termination");
|
||||
"parse() responding to job termination");
|
||||
}
|
||||
|
||||
if(allTablesDone(WriteEngine::PARSE_COMPLETE))
|
||||
if (allTablesDone(WriteEngine::PARSE_COMPLETE))
|
||||
{
|
||||
#ifdef PROFILE
|
||||
Stats::stopParseEvent(WE_STATS_WAIT_TO_SELECT_COL);
|
||||
@ -242,25 +255,28 @@ void BulkLoad::parse(int id)
|
||||
return;
|
||||
}
|
||||
|
||||
if(lockColumnForParse(id, tableId, columnId,
|
||||
myParseBuffer, report))
|
||||
if (lockColumnForParse(id, tableId, columnId,
|
||||
myParseBuffer, report))
|
||||
break;
|
||||
|
||||
// Sleep and check the condition again.
|
||||
sleepMS(1);
|
||||
#ifdef DEADLOCK_DEBUG
|
||||
|
||||
// @bug2099+
|
||||
if(report) report = false; // report one time.
|
||||
if(!reported)
|
||||
if (report) report = false; // report one time.
|
||||
|
||||
if (!reported)
|
||||
{
|
||||
struct timeval tvNow;
|
||||
gettimeofday(&tvNow, 0);
|
||||
if((tvNow.tv_sec - tvStart.tv_sec) >= 100)
|
||||
|
||||
if ((tvNow.tv_sec - tvStart.tv_sec) >= 100)
|
||||
{
|
||||
time_t t = time(0);
|
||||
char timeString[50];
|
||||
ctime_r(&t, timeString);
|
||||
timeString[ strlen(timeString)-1 ] = '\0';
|
||||
timeString[ strlen(timeString) - 1 ] = '\0';
|
||||
ostringstream oss;
|
||||
oss << endl << endl << timeString <<
|
||||
": BulkLoad::parse(" << id << "); " <<
|
||||
@ -278,18 +294,21 @@ void BulkLoad::parse(int id)
|
||||
reported = true;
|
||||
}
|
||||
}
|
||||
|
||||
// @bug2099-
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PROFILE
|
||||
Stats::stopParseEvent(WE_STATS_WAIT_TO_SELECT_COL);
|
||||
#endif
|
||||
// Have obtained the table and column for parsing.
|
||||
// Start parsing the column data.
|
||||
double processingTime;
|
||||
int rc = fTableInfo[tableId].parseColumn(columnId,myParseBuffer,
|
||||
processingTime);
|
||||
if(rc != NO_ERROR)
|
||||
int rc = fTableInfo[tableId].parseColumn(columnId, myParseBuffer,
|
||||
processingTime);
|
||||
|
||||
if (rc != NO_ERROR)
|
||||
{
|
||||
// Error occurred while parsing the data, break out of loop.
|
||||
BulkStatus::setJobStatus( EXIT_FAILURE );
|
||||
@ -307,7 +326,7 @@ void BulkLoad::parse(int id)
|
||||
|
||||
// Parsing is complete. Acquire the mutex and increment
|
||||
// the parsingComplete value for the buffer
|
||||
if(fTableInfo[tableId].getStatusTI() != WriteEngine::ERR)
|
||||
if (fTableInfo[tableId].getStatusTI() != WriteEngine::ERR)
|
||||
{
|
||||
#ifdef PROFILE
|
||||
Stats::startParseEvent(WE_STATS_WAIT_TO_COMPLETE_PARSE);
|
||||
@ -318,8 +337,9 @@ void BulkLoad::parse(int id)
|
||||
Stats::startParseEvent(WE_STATS_COMPLETING_PARSE);
|
||||
#endif
|
||||
rc = fTableInfo[tableId].setParseComplete(columnId,
|
||||
myParseBuffer,
|
||||
processingTime);
|
||||
myParseBuffer,
|
||||
processingTime);
|
||||
|
||||
if (rc != NO_ERROR)
|
||||
{
|
||||
BulkStatus::setJobStatus( EXIT_FAILURE );
|
||||
@ -334,6 +354,7 @@ void BulkLoad::parse(int id)
|
||||
setParseErrorOnTable( tableId, false );
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef PROFILE
|
||||
Stats::stopParseEvent(WE_STATS_COMPLETING_PARSE);
|
||||
#endif
|
||||
@ -344,24 +365,30 @@ void BulkLoad::parse(int id)
|
||||
{
|
||||
// We are bailing out because another thread set bad job status
|
||||
ostringstream oss;
|
||||
if (tableId != -1) {
|
||||
|
||||
if (tableId != -1)
|
||||
{
|
||||
oss << "Bulkload Parse (thread " << id <<
|
||||
") Stopped parsing Table " <<
|
||||
fTableInfo[tableId].getTableName() << ". " << ex.what();
|
||||
|
||||
setParseErrorOnTable( tableId, true );
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
oss << "Bulkload Parse (thread " << id <<
|
||||
") Stopped parsing Tables. " << ex.what();
|
||||
}
|
||||
|
||||
fLog.logMsg( oss.str(), MSGLVL_INFO1 );
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
BulkStatus::setJobStatus( EXIT_FAILURE );
|
||||
ostringstream oss;
|
||||
if (tableId != -1) {
|
||||
|
||||
if (tableId != -1)
|
||||
{
|
||||
oss << "Bulkload Parse (thread " << id <<
|
||||
") Failed for Table " <<
|
||||
fTableInfo[tableId].getTableName() << ". " << ex.what() <<
|
||||
@ -370,18 +397,22 @@ void BulkLoad::parse(int id)
|
||||
setParseErrorOnTable( tableId, true );
|
||||
fTableInfo[tableId].fBRMReporter.addToErrMsgEntry(oss.str());
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
oss << "Bulkload Parse (thread " << id <<
|
||||
") Failed for Table. " << ex.what() <<
|
||||
". Terminating this job.";
|
||||
}
|
||||
fLog.logMsg( oss.str(), ERR_UNKNOWN, MSGLVL_CRITICAL );
|
||||
|
||||
fLog.logMsg( oss.str(), ERR_UNKNOWN, MSGLVL_CRITICAL );
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BulkStatus::setJobStatus( EXIT_FAILURE );
|
||||
ostringstream oss;
|
||||
if (tableId != -1) {
|
||||
|
||||
if (tableId != -1)
|
||||
{
|
||||
oss << "Bulkload Parse (thread " << id <<
|
||||
") Failed for Table " <<
|
||||
fTableInfo[tableId].getTableName() <<
|
||||
@ -390,11 +421,13 @@ void BulkLoad::parse(int id)
|
||||
setParseErrorOnTable( tableId, true );
|
||||
fTableInfo[tableId].fBRMReporter.addToErrMsgEntry(oss.str());
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
oss << "Bulkload Parse (thread " << id <<
|
||||
") Failed for Table. Terminating this job.";
|
||||
}
|
||||
fLog.logMsg( oss.str(), ERR_UNKNOWN, MSGLVL_CRITICAL );
|
||||
|
||||
fLog.logMsg( oss.str(), ERR_UNKNOWN, MSGLVL_CRITICAL );
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,11 +439,11 @@ void BulkLoad::parse(int id)
|
||||
//------------------------------------------------------------------------------
|
||||
// @bug2099 - Temp hack to diagnose deadlock. Added report parm and couts below.
|
||||
bool BulkLoad::lockColumnForParse(
|
||||
int thrdId,
|
||||
int & tableId,
|
||||
int & columnId,
|
||||
int & myParseBuffer,
|
||||
bool report)
|
||||
int thrdId,
|
||||
int& tableId,
|
||||
int& columnId,
|
||||
int& myParseBuffer,
|
||||
bool report)
|
||||
{
|
||||
// Acquire mutex
|
||||
// Iterate on the table list
|
||||
@ -419,17 +452,18 @@ bool BulkLoad::lockColumnForParse(
|
||||
// else, go to the next table for checking if a column is available
|
||||
boost::mutex::scoped_lock lock(fParseMutex);
|
||||
|
||||
for(unsigned i=0; i<fTableInfo.size(); ++i)
|
||||
for (unsigned i = 0; i < fTableInfo.size(); ++i)
|
||||
{
|
||||
if (fTableInfo[i].getStatusTI() == WriteEngine::PARSE_COMPLETE)
|
||||
continue;
|
||||
|
||||
int currentParseBuffer = fTableInfo[i].getCurrentParseBuffer();
|
||||
myParseBuffer = currentParseBuffer;
|
||||
|
||||
do
|
||||
{
|
||||
// @bug2099+
|
||||
if(report)
|
||||
if (report)
|
||||
{
|
||||
ostringstream oss;
|
||||
std::string bufStatusStr;
|
||||
@ -443,27 +477,31 @@ bool BulkLoad::lockColumnForParse(
|
||||
#endif
|
||||
":fTableInfo[" << i << "]" << bufStatusStr << " (" <<
|
||||
stat << ")";
|
||||
|
||||
if ( stat != WriteEngine::PARSE_COMPLETE )
|
||||
{
|
||||
oss << "; fCurrentParseBuffer is " << myParseBuffer;
|
||||
}
|
||||
|
||||
oss << endl;
|
||||
cout << oss.str();
|
||||
cout.flush();
|
||||
}
|
||||
|
||||
// @bug2099-
|
||||
|
||||
// get a buffer and column to parse if available.
|
||||
if((columnId = fTableInfo[i].getColumnForParse(
|
||||
thrdId,myParseBuffer,report )) != -1)
|
||||
if ((columnId = fTableInfo[i].getColumnForParse(
|
||||
thrdId, myParseBuffer, report )) != -1)
|
||||
{
|
||||
tableId = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
myParseBuffer = (myParseBuffer + 1) %
|
||||
fTableInfo[i].getNumberOfBuffers();
|
||||
}
|
||||
while(myParseBuffer != currentParseBuffer);
|
||||
}
|
||||
while (myParseBuffer != currentParseBuffer);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -481,11 +519,12 @@ bool BulkLoad::lockColumnForParse(
|
||||
//------------------------------------------------------------------------------
|
||||
bool BulkLoad::allTablesDone(Status status)
|
||||
{
|
||||
for(unsigned i=0; i<fTableInfo.size(); ++i)
|
||||
for (unsigned i = 0; i < fTableInfo.size(); ++i)
|
||||
{
|
||||
if(fTableInfo[i].getStatusTI() == WriteEngine::ERR)
|
||||
if (fTableInfo[i].getStatusTI() == WriteEngine::ERR)
|
||||
return true;
|
||||
if(fTableInfo[i].getStatusTI() != status)
|
||||
|
||||
if (fTableInfo[i].getStatusTI() != status)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user