mirror of https://gitee.com/bigwinds/arangodb
Fixed database/collection lookup in cluster. It did not get the correct vocbase when using a Database other than _system
This commit is contained in:
parent
793a157b16
commit
efce89e3f4
|
@ -430,7 +430,12 @@ void ClusterInfo::loadPlan() {
|
|||
}
|
||||
DatabaseCollections databaseCollections;
|
||||
std::string const databaseName = databasePairSlice.key.copyString();
|
||||
TRI_vocbase_t* vocbase = databaseFeature->lookupDatabase(databaseName);
|
||||
TRI_vocbase_t* vocbase = nullptr;
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
vocbase = databaseFeature->lookupDatabaseCoordinator(databaseName);
|
||||
} else {
|
||||
vocbase = databaseFeature->lookupDatabase(databaseName);
|
||||
}
|
||||
TRI_ASSERT(vocbase != nullptr);
|
||||
if (vocbase == nullptr) {
|
||||
// No database with this name found.
|
||||
|
|
|
@ -676,7 +676,9 @@ static void JS_GetCollectionInfoClusterInfo(
|
|||
|
||||
std::shared_ptr<LogicalCollection> ci = ClusterInfo::instance()->getCollection(
|
||||
TRI_ObjectToString(args[0]), TRI_ObjectToString(args[1]));
|
||||
TRI_ASSERT(ci != nullptr);
|
||||
if (ci == nullptr) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
v8::Handle<v8::Object> result = v8::Object::New(isolate);
|
||||
std::string const cid = ci->cid_as_string();
|
||||
|
|
|
@ -468,7 +468,6 @@ int DatabaseFeature::createDatabaseCoordinator(TRI_voc_tick_t id, std::string co
|
|||
|
||||
result = vocbase.get();
|
||||
vocbase.release();
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -884,6 +883,24 @@ TRI_vocbase_t* DatabaseFeature::useDatabase(TRI_voc_tick_t id) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
/// @brief lookup a database by its name, not increasing its reference count
|
||||
TRI_vocbase_t* DatabaseFeature::lookupDatabaseCoordinator(
|
||||
std::string const& name) {
|
||||
auto unuser(_databasesProtector.use());
|
||||
auto theLists = _databasesLists.load();
|
||||
|
||||
auto it = theLists->_coordinatorDatabases.find(name);
|
||||
|
||||
if (it != theLists->_coordinatorDatabases.end()) {
|
||||
TRI_vocbase_t* vocbase = it->second;
|
||||
return vocbase;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief lookup a database by its name, not increasing its reference count
|
||||
TRI_vocbase_t* DatabaseFeature::lookupDatabase(std::string const& name) {
|
||||
auto unuser(_databasesProtector.use());
|
||||
|
|
|
@ -95,6 +95,7 @@ class DatabaseFeature final : public application_features::ApplicationFeature {
|
|||
TRI_vocbase_t* useDatabase(std::string const& name);
|
||||
TRI_vocbase_t* useDatabase(TRI_voc_tick_t id);
|
||||
|
||||
TRI_vocbase_t* lookupDatabaseCoordinator(std::string const& name);
|
||||
TRI_vocbase_t* lookupDatabase(std::string const& name);
|
||||
|
||||
void useSystemDatabase();
|
||||
|
|
Loading…
Reference in New Issue