mirror of https://gitee.com/bigwinds/arangodb
Bug fix 3.5/always create analyzers collection 35 (#10356)
* always create `_analyzers` collection if missing * Update arangod/IResearch/IResearchAnalyzerCollectionFeature.cpp Co-Authored-By: Andrey Abramov <andrey@arangodb.com> * Update arangod/IResearch/IResearchAnalyzerCollectionFeature.cpp Co-Authored-By: Andrey Abramov <andrey@arangodb.com> * Update arangod/IResearch/IResearchAnalyzerCollectionFeature.cpp Co-Authored-By: Andrey Abramov <andrey@arangodb.com> * Update arangod/IResearch/IResearchAnalyzerCollectionFeature.cpp Co-Authored-By: Andrey Abramov <andrey@arangodb.com> * add missing include
This commit is contained in:
parent
ac050be233
commit
461ea7cb5e
|
@ -52,6 +52,7 @@ add_library(${LIB_ARANGO_IRESEARCH}
|
|||
IResearch/ApplicationServerHelper.h IResearch/ApplicationServerHelper.cpp
|
||||
IResearch/Containers.cpp IResearch/Containers.h
|
||||
IResearch/IResearchAnalyzerFeature.cpp IResearch/IResearchAnalyzerFeature.h
|
||||
IResearch/IResearchAnalyzerCollectionFeature.cpp
|
||||
IResearch/IResearchCommon.cpp IResearch/IResearchCommon.h
|
||||
IResearch/IResearchKludge.cpp IResearch/IResearchKludge.h
|
||||
IResearch/IResearchLink.cpp IResearch/IResearchLink.h
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2017 ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Jan Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ApplicationServerHelper.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "IResearch/IResearchAnalyzerCollectionFeature.h"
|
||||
#include "IResearch/IResearchCommon.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "RestServer/DatabaseFeature.h"
|
||||
#include "VocBase/Methods/Collections.h"
|
||||
|
||||
using namespace arangodb;
|
||||
|
||||
IResearchAnalyzerCollectionFeature::IResearchAnalyzerCollectionFeature(application_features::ApplicationServer& server)
|
||||
: ApplicationFeature(server, "ArangoSearchAnalyzerCollection") {
|
||||
setOptional(true);
|
||||
startsAfter("DatabasePhase");
|
||||
// should be relatively late in startup sequence
|
||||
startsAfter("ClusterPhase");
|
||||
startsAfter("ServerPhase");
|
||||
startsAfter("Bootstrap");
|
||||
}
|
||||
|
||||
void IResearchAnalyzerCollectionFeature::start() {
|
||||
if (ServerState::instance()->isDBServer()) {
|
||||
// no need to execute this in DB server
|
||||
return;
|
||||
}
|
||||
|
||||
DatabaseFeature* databaseFeature = DatabaseFeature::DATABASE;
|
||||
TRI_ASSERT(databaseFeature != nullptr);
|
||||
|
||||
databaseFeature->enumerateDatabases([](TRI_vocbase_t& vocbase) {
|
||||
Result res = methods::Collections::lookup(vocbase, StaticStrings::AnalyzersCollection, [](std::shared_ptr<LogicalCollection> const&) {
|
||||
});
|
||||
|
||||
if (res.is(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND)) {
|
||||
// collection does not yet exist, so let's create it now
|
||||
auto res = methods::Collections::createSystem(vocbase, StaticStrings::AnalyzersCollection, false);
|
||||
if (res.first.ok()) {
|
||||
LOG_TOPIC("c2e33", DEBUG, arangodb::iresearch::TOPIC) << "successfully created '" << StaticStrings::AnalyzersCollection << "' collection in database '" << vocbase.name() << "'";
|
||||
} else if (res.first.fail() && !res.first.is(TRI_ERROR_ARANGO_CONFLICT)) {
|
||||
LOG_TOPIC("ecc23", WARN, arangodb::iresearch::TOPIC) << "unable to create '" << StaticStrings::AnalyzersCollection << "' collection: " << res.first.errorMessage();
|
||||
// don't abort startup here. the next startup may fix this
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2017 ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Jan Steemann
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGOD_IRESEARCH__IRESEARCH_ANALYZER_COLLECTION_FEATURE_H
|
||||
#define ARANGOD_IRESEARCH__IRESEARCH_ANALYZER_COLLECTION_FEATURE_H 1
|
||||
|
||||
#include "ApplicationFeatures/ApplicationFeature.h"
|
||||
|
||||
namespace arangodb {
|
||||
|
||||
/// @brief the sole purpose of this feature is to create potentially
|
||||
/// missing `_analyzers` collection after startup. It can be removed
|
||||
/// eventually once the entire upgrading logic has been revised
|
||||
class IResearchAnalyzerCollectionFeature final : public arangodb::application_features::ApplicationFeature {
|
||||
public:
|
||||
explicit IResearchAnalyzerCollectionFeature(arangodb::application_features::ApplicationServer& server);
|
||||
|
||||
void start() override;
|
||||
};
|
||||
|
||||
} // namespace arangodb
|
||||
|
||||
#endif
|
|
@ -116,6 +116,7 @@
|
|||
#endif
|
||||
|
||||
#include "IResearch/IResearchAnalyzerFeature.h"
|
||||
#include "IResearch/IResearchAnalyzerCollectionFeature.h"
|
||||
#include "IResearch/IResearchFeature.h"
|
||||
|
||||
// storage engines
|
||||
|
@ -245,6 +246,7 @@ static int runServer(int argc, char** argv, ArangoGlobalContext& context) {
|
|||
|
||||
server.addFeature(new arangodb::iresearch::IResearchAnalyzerFeature(server));
|
||||
server.addFeature(new arangodb::iresearch::IResearchFeature(server));
|
||||
server.addFeature(new arangodb::IResearchAnalyzerCollectionFeature(server));
|
||||
|
||||
// storage engines
|
||||
server.addFeature(new ClusterEngine(server));
|
||||
|
|
Loading…
Reference in New Issue