You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-06-13 16:01:32 +03:00
Merge branch 'develop-1.1' into develop-1.2-merge-up-20190517
This commit is contained in:
@ -349,7 +349,7 @@ PackageHandler::~PackageHandler()
|
||||
// Rollback will most likely be next.
|
||||
//
|
||||
// A tranasaction for one fTableOid is not blocked by a txn for a different fTableOid.
|
||||
int PackageHandler::synchTableAccess()
|
||||
int PackageHandler::synchTableAccess(dmlpackage::CalpontDMLPackage* dmlPackage)
|
||||
{
|
||||
// MCOL-140 Wait for any other DML using this table.
|
||||
std::map<uint32_t, PackageHandler::tableAccessQueue_t>::iterator it;
|
||||
@ -393,10 +393,27 @@ int PackageHandler::synchTableAccess()
|
||||
// tableOidQueue here is the queue holding the waitng transactions for this fTableOid
|
||||
while (true)
|
||||
{
|
||||
// Log something that we're waiting
|
||||
LoggingID logid(21, fSessionID, fTxnid);
|
||||
logging::Message::Args args1;
|
||||
logging::Message msg(1);
|
||||
ostringstream oss;
|
||||
oss << "Txn is waiting for" << tableOidQueue.front() << " " << dmlPackage->get_SQLStatement() << "; |" << dmlPackage->get_SchemaName() <<"|";
|
||||
args1.add(oss.str());
|
||||
args1.add((uint64_t)fTableOid);
|
||||
msg.format(args1);
|
||||
logging::Logger logger(logid.fSubsysID);
|
||||
logger.logMessage(LOG_TYPE_DEBUG, msg, logid);
|
||||
|
||||
tableOidCond.wait(lock);
|
||||
|
||||
// In case of CTRL+C, the tableOidQueue could be invalidated
|
||||
if ((tableOidMap.find(fTableOid))->second != tableOidQueue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (tableOidQueue.front() == fTxnid)
|
||||
{
|
||||
// We're up next. Let's go do stuff.
|
||||
break;
|
||||
}
|
||||
|
||||
@ -439,7 +456,6 @@ int PackageHandler::releaseTableAccess()
|
||||
|
||||
if (fTableOid == 0 || (it = tableOidMap.find(fTableOid)) == tableOidMap.end())
|
||||
{
|
||||
// This will happen for DML_COMMAND, as we never got the tableoid or called synchTableAccess
|
||||
return 2; // For now, return codes are not used
|
||||
}
|
||||
|
||||
@ -461,7 +477,8 @@ int PackageHandler::releaseTableAccess()
|
||||
}
|
||||
else
|
||||
{
|
||||
tableOidQueue.pop(); // Get off the waiting list.
|
||||
if (!tableOidQueue.empty())
|
||||
tableOidQueue.pop(); // Get off the waiting list.
|
||||
|
||||
if (tableOidQueue.empty())
|
||||
{
|
||||
@ -477,7 +494,7 @@ int PackageHandler::releaseTableAccess()
|
||||
|
||||
int PackageHandler::forceReleaseTableAccess()
|
||||
{
|
||||
// By removing the tcnid from the queue, the logic after the wait in
|
||||
// By removing the txnid from the queue, the logic after the wait in
|
||||
// synchTableAccess() will release the thread and clean up if needed.
|
||||
std::map<uint32_t, PackageHandler::tableAccessQueue_t>::iterator it;
|
||||
boost::lock_guard<boost::mutex> lock(tableOidMutex);
|
||||
@ -490,6 +507,11 @@ int PackageHandler::forceReleaseTableAccess()
|
||||
|
||||
PackageHandler::tableAccessQueue_t& tableOidQueue = it->second;
|
||||
tableOidQueue.erase(fTxnid);
|
||||
if (tableOidQueue.empty())
|
||||
{
|
||||
// remove the queue from the map.
|
||||
tableOidMap.erase(fTableOid);
|
||||
}
|
||||
// release the condition
|
||||
tableOidCond.notify_all();
|
||||
return 1;
|
||||
@ -513,7 +535,8 @@ void PackageHandler::run()
|
||||
std::string stmt;
|
||||
unsigned DMLLoggingId = 21;
|
||||
oam::OamCache* oamCache = oam::OamCache::makeOamCache();
|
||||
|
||||
SynchTable synchTable;
|
||||
|
||||
try
|
||||
{
|
||||
switch ( fPackageType )
|
||||
@ -542,8 +565,7 @@ void PackageHandler::run()
|
||||
CalpontSystemCatalog::ROPair roPair = fcsc->tableRID(tableName);
|
||||
fTableOid = roPair.objnum;
|
||||
}
|
||||
|
||||
synchTableAccess(); // Blocks if another DML thread is using this fTableOid
|
||||
synchTable.setPackage(this, &insertPkg); // Blocks if another DML thread is using this fTableOid
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -921,8 +943,7 @@ void PackageHandler::run()
|
||||
CalpontSystemCatalog::ROPair roPair = fcsc->tableRID(tableName);
|
||||
fTableOid = roPair.objnum;
|
||||
}
|
||||
|
||||
synchTableAccess(); // Blocks if another DML thread is using this fTableOid
|
||||
synchTable.setPackage(this, updatePkg.get()); // Blocks if another DML thread is using this fTableOid
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -981,8 +1002,7 @@ void PackageHandler::run()
|
||||
CalpontSystemCatalog::ROPair roPair = fcsc->tableRID(tableName);
|
||||
fTableOid = roPair.objnum;
|
||||
}
|
||||
|
||||
synchTableAccess(); // Blocks if another DML thread is using this fTableOid
|
||||
synchTable.setPackage(this, deletePkg.get()); // Blocks if another DML thread is using this fTableOid
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1049,15 +1069,8 @@ void PackageHandler::run()
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef MCOL_140
|
||||
|
||||
if (fConcurrentSupport)
|
||||
{
|
||||
// MCOL-140 We're done. release the next waiting txn for this fTableOid
|
||||
releaseTableAccess();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//Log errors
|
||||
if ( (result.result != dmlpackageprocessor::DMLPackageProcessor::NO_ERROR)
|
||||
@ -1080,15 +1093,8 @@ void PackageHandler::run()
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
#ifdef MCOL_140
|
||||
|
||||
if (fConcurrentSupport)
|
||||
{
|
||||
// MCOL-140 We're done. release the next waiting txn for this fTableOid
|
||||
releaseTableAccess();
|
||||
}
|
||||
|
||||
#endif
|
||||
cout << "dmlprocessor.cpp PackageHandler::run() package type("
|
||||
<< fPackageType << ") exception: " << e.what() << endl;
|
||||
logging::LoggingID lid(21);
|
||||
@ -1105,15 +1111,8 @@ void PackageHandler::run()
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
#ifdef MCOL_140
|
||||
|
||||
if (fConcurrentSupport)
|
||||
{
|
||||
// MCOL-140 We're done. release the next waiting txn for this fTableOid
|
||||
releaseTableAccess();
|
||||
}
|
||||
|
||||
#endif
|
||||
logging::LoggingID lid(21);
|
||||
logging::MessageLog ml(lid);
|
||||
logging::Message::Args args;
|
||||
@ -1157,9 +1156,17 @@ void PackageHandler::run()
|
||||
|
||||
void PackageHandler::rollbackPending()
|
||||
{
|
||||
if (fProcessor.get() == NULL)
|
||||
{
|
||||
// This happens when batch insert
|
||||
return;
|
||||
}
|
||||
|
||||
fProcessor->setRollbackPending(true);
|
||||
|
||||
// Force a release of the processing from MCOL-140
|
||||
#ifdef MCOL_140
|
||||
if (fConcurrentSupport)
|
||||
if (fConcurrentSupport)
|
||||
{
|
||||
// MCOL-140 We're not necessarily the next in line.
|
||||
// This forces this thread to be released anyway.
|
||||
@ -1168,14 +1175,6 @@ void PackageHandler::rollbackPending()
|
||||
|
||||
#endif
|
||||
|
||||
if (fProcessor.get() == NULL)
|
||||
{
|
||||
// This happens when batch insert
|
||||
return;
|
||||
}
|
||||
|
||||
fProcessor->setRollbackPending(true);
|
||||
|
||||
ostringstream oss;
|
||||
oss << "PackageHandler::rollbackPending: Processing DMLPackage.";
|
||||
DMLProcessor::log(oss.str(), logging::LOG_TYPE_DEBUG);
|
||||
|
Reference in New Issue
Block a user