mirror of https://gitee.com/bigwinds/arangodb
Start building proper cleanup if instanciation throws in between.
This commit is contained in:
parent
425d50bdc1
commit
9fcdc1fa94
|
@ -419,7 +419,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
|
||||||
// this is relevant to decide whether or not the engine there is a main
|
// this is relevant to decide whether or not the engine there is a main
|
||||||
// query or a dependent one.
|
// query or a dependent one.
|
||||||
std::unordered_map<std::string, std::string> queryIds;
|
std::unordered_map<std::string, std::string> queryIds;
|
||||||
// map from itoa(ID of RemoteNode in original plan) + shardId
|
// map from itoa(ID of RemoteNode in original plan) + "_" + shardId
|
||||||
// to queryId on DBserver
|
// to queryId on DBserver
|
||||||
// this is built up when we instanciate the various engines on the
|
// this is built up when we instanciate the various engines on the
|
||||||
// DBservers and used when we instanciate the one using them on the
|
// DBservers and used when we instanciate the one using them on the
|
||||||
|
@ -588,7 +588,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
|
||||||
// std::cout << "DB SERVER ANSWERED WITHOUT ERROR: " << res->answer->body() << ", REMOTENODEID: " << info.idOfRemoteNode << " SHARDID:" << res->shardID << ", QUERYID: " << queryId << "\n";
|
// std::cout << "DB SERVER ANSWERED WITHOUT ERROR: " << res->answer->body() << ", REMOTENODEID: " << info.idOfRemoteNode << " SHARDID:" << res->shardID << ", QUERYID: " << queryId << "\n";
|
||||||
std::string theID
|
std::string theID
|
||||||
= triagens::basics::StringUtils::itoa(info.idOfRemoteNode)
|
= triagens::basics::StringUtils::itoa(info.idOfRemoteNode)
|
||||||
+ res->shardID;
|
+ "_" + res->shardID;
|
||||||
queryIds.emplace(std::make_pair(theID, queryId));
|
queryIds.emplace(std::make_pair(theID, queryId));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -706,7 +706,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
|
||||||
for (auto const& shardId : shardIds) {
|
for (auto const& shardId : shardIds) {
|
||||||
std::string theId
|
std::string theId
|
||||||
= triagens::basics::StringUtils::itoa(remoteNode->id())
|
= triagens::basics::StringUtils::itoa(remoteNode->id())
|
||||||
+ shardId;
|
+ "_" + shardId;
|
||||||
auto it = queryIds.find(theId);
|
auto it = queryIds.find(theId);
|
||||||
if (it == queryIds.end()) {
|
if (it == queryIds.end()) {
|
||||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "could not find query id in list");
|
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "could not find query id in list");
|
||||||
|
@ -764,6 +764,8 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
|
||||||
id = TRI_NewTickServer();
|
id = TRI_NewTickServer();
|
||||||
|
|
||||||
queryRegistry->insert(id, engine->getQuery(), 3600.0);
|
queryRegistry->insert(id, engine->getQuery(), 3600.0);
|
||||||
|
// TODO: put an entry into queryIds such that we can delete
|
||||||
|
// this one here if things go wrong during instanciation.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -836,16 +838,6 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
|
||||||
// --SECTION-- public functions
|
// --SECTION-- public functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief add a block to the engine
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void ExecutionEngine::addBlock (ExecutionBlock* block) {
|
|
||||||
TRI_ASSERT(block != nullptr);
|
|
||||||
|
|
||||||
_blocks.push_back(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief create an execution engine from a plan
|
/// @brief create an execution engine from a plan
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -884,9 +876,36 @@ ExecutionEngine* ExecutionEngine::instanciateFromPlan (QueryRegistry* queryRegis
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
try {
|
||||||
engine = inst.get()->buildEngines();
|
engine = inst.get()->buildEngines();
|
||||||
root = engine->root();
|
root = engine->root();
|
||||||
}
|
}
|
||||||
|
catch (...) {
|
||||||
|
// We need to destroy all queries that we have built and stuffed
|
||||||
|
// into the QueryRegistry as well as those that we have pushed to
|
||||||
|
// the DBservers via HTTP:
|
||||||
|
// TODOTODOTODO
|
||||||
|
#if 0
|
||||||
|
for (auto& q : queryIds) {
|
||||||
|
std::string theId = q.first;
|
||||||
|
std::string queryId = q.second;
|
||||||
|
auto pos = theId.find('_');
|
||||||
|
TRI_ASSERT(pos != std::string::npos);
|
||||||
|
size_t engineId = triagens::basics::uint64(theId.substr(0,pos));
|
||||||
|
std::string shardId = theId.substr(pos+1);
|
||||||
|
if (engines[engineId].location == COORDINATOR) {
|
||||||
|
// Remove query from registry:
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Remove query from DBserver:
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// instanciate the engine on a local server
|
// instanciate the engine on a local server
|
||||||
engine = new ExecutionEngine(query);
|
engine = new ExecutionEngine(query);
|
||||||
|
@ -908,6 +927,16 @@ ExecutionEngine* ExecutionEngine::instanciateFromPlan (QueryRegistry* queryRegis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief add a block to the engine
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void ExecutionEngine::addBlock (ExecutionBlock* block) {
|
||||||
|
TRI_ASSERT(block != nullptr);
|
||||||
|
|
||||||
|
_blocks.push_back(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- END-OF-FILE
|
// --SECTION-- END-OF-FILE
|
||||||
|
|
Loading…
Reference in New Issue