diff --git a/arangod/RestServer/CheckVersionFeature.cpp b/arangod/RestServer/CheckVersionFeature.cpp index c24a80ba54..2fa38e1b1f 100644 --- a/arangod/RestServer/CheckVersionFeature.cpp +++ b/arangod/RestServer/CheckVersionFeature.cpp @@ -97,6 +97,10 @@ void CheckVersionFeature::start() { // and force shutdown server()->beginShutdown(); + + LOG(DEBUG) << "checking version on an empty database"; + usleep(1 * 1000 * 1000); + TRI_EXIT_FUNCTION(EXIT_SUCCESS, nullptr); } void CheckVersionFeature::checkVersion() { diff --git a/arangod/RestServer/DatabaseFeature.cpp b/arangod/RestServer/DatabaseFeature.cpp index 05586aca8b..c422f35c12 100644 --- a/arangod/RestServer/DatabaseFeature.cpp +++ b/arangod/RestServer/DatabaseFeature.cpp @@ -341,7 +341,7 @@ void DatabaseFeature::start() { } // TODO: handle _upgrade and _checkVersion here - + // activate deadlock detection in case we're not running in cluster mode if (!arangodb::ServerState::instance()->isRunningInCluster()) { enableDeadlockDetection(); diff --git a/arangod/RestServer/DatabaseFeature.h b/arangod/RestServer/DatabaseFeature.h index 06a988116b..15e86e9c49 100644 --- a/arangod/RestServer/DatabaseFeature.h +++ b/arangod/RestServer/DatabaseFeature.h @@ -119,6 +119,7 @@ class DatabaseFeature final : public application_features::ApplicationFeature { bool throwCollectionNotLoadedError() const { return _throwCollectionNotLoadedError.load(std::memory_order_relaxed); } void throwCollectionNotLoadedError(bool value) { _throwCollectionNotLoadedError.store(value); } bool check30Revisions() const { return _check30Revisions; } + void isInitiallyEmpty(bool value) { _isInitiallyEmpty = value; } private: void closeDatabases(); diff --git a/arangod/RestServer/ServerIdFeature.cpp b/arangod/RestServer/ServerIdFeature.cpp index 9f71100d39..bbe481df5c 100644 --- a/arangod/RestServer/ServerIdFeature.cpp +++ b/arangod/RestServer/ServerIdFeature.cpp @@ -51,9 +51,18 @@ void ServerIdFeature::start() { auto database = application_features::ApplicationServer::getFeature("Database"); // read the server id or create a new one - int res = determineId(database->checkVersion()); + bool const checkVersion = database->checkVersion(); + int res = determineId(checkVersion); if (res == TRI_ERROR_ARANGO_EMPTY_DATADIR) { + if (checkVersion) { + // when we are version checking, we will not fail here + // additionally notify the database feature that we had no VERSION file + database->isInitiallyEmpty(true); + return; + } + + // otherwise fail THROW_ARANGO_EXCEPTION(res); }