1
0
Fork 0

fix --database.check-version on an empty directory

This commit is contained in:
Jan Steemann 2016-11-02 16:53:38 +01:00
parent d82079a59c
commit b9d345ff67
4 changed files with 16 additions and 2 deletions

View File

@ -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() {

View File

@ -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();

View File

@ -51,9 +51,18 @@ void ServerIdFeature::start() {
auto database = application_features::ApplicationServer::getFeature<DatabaseFeature>("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);
}