diff --git a/arangod/VocBase/replication-applier.cpp b/arangod/VocBase/replication-applier.cpp index c22155f229..956b53c514 100644 --- a/arangod/VocBase/replication-applier.cpp +++ b/arangod/VocBase/replication-applier.cpp @@ -231,8 +231,6 @@ static int LoadConfiguration (TRI_vocbase_t* vocbase, return TRI_ERROR_REPLICATION_INVALID_APPLIER_CONFIGURATION; } - int res = TRI_ERROR_NO_ERROR; - if (config->_endpoint != nullptr) { TRI_FreeString(TRI_CORE_MEM_ZONE, config->_endpoint); config->_endpoint = nullptr; @@ -250,20 +248,8 @@ static int LoadConfiguration (TRI_vocbase_t* vocbase, config->_password = nullptr; } - // read the endpoint - TRI_json_t const* value = TRI_LookupObjectJson(json.get(), "endpoint"); - - if (! TRI_IsStringJson(value)) { - res = TRI_ERROR_REPLICATION_INVALID_APPLIER_CONFIGURATION; - } - else { - config->_endpoint = TRI_DuplicateString2Z(TRI_CORE_MEM_ZONE, - value->_value._string.data, - value->_value._string.length - 1); - } - // read the database name - value = TRI_LookupObjectJson(json.get(), "database"); + TRI_json_t const* value = TRI_LookupObjectJson(json.get(), "database"); if (! TRI_IsStringJson(value)) { config->_database = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, @@ -385,8 +371,21 @@ static int LoadConfiguration (TRI_vocbase_t* vocbase, } } } + + // read the endpoint + value = TRI_LookupObjectJson(json.get(), "endpoint"); - return res; + if (! TRI_IsStringJson(value)) { + // we haven't found an endpoint. now don't let the start fail but continue + config->_autoStart = false; + } + else { + config->_endpoint = TRI_DuplicateString2Z(TRI_CORE_MEM_ZONE, + value->_value._string.data, + value->_value._string.length - 1); + } + + return TRI_ERROR_NO_ERROR; } //////////////////////////////////////////////////////////////////////////////// @@ -559,10 +558,6 @@ TRI_replication_applier_t* TRI_CreateReplicationApplier (TRI_server_t* server, TRI_vocbase_t* vocbase) { TRI_replication_applier_t* applier = new TRI_replication_applier_t(server, vocbase); - if (applier == nullptr) { - return nullptr; - } - TRI_InitConfigurationReplicationApplier(&applier->_configuration); TRI_InitStateReplicationApplier(&applier->_state); @@ -571,10 +566,10 @@ TRI_replication_applier_t* TRI_CreateReplicationApplier (TRI_server_t* server, if (res != TRI_ERROR_NO_ERROR && res != TRI_ERROR_FILE_NOT_FOUND) { - TRI_set_errno(res); TRI_DestroyStateReplicationApplier(&applier->_state); TRI_DestroyConfigurationReplicationApplier(&applier->_configuration); delete applier; + TRI_set_errno(res); return nullptr; } @@ -583,10 +578,10 @@ TRI_replication_applier_t* TRI_CreateReplicationApplier (TRI_server_t* server, if (res != TRI_ERROR_NO_ERROR && res != TRI_ERROR_FILE_NOT_FOUND) { - TRI_set_errno(res); TRI_DestroyStateReplicationApplier(&applier->_state); TRI_DestroyConfigurationReplicationApplier(&applier->_configuration); delete applier; + TRI_set_errno(res); return nullptr; } @@ -897,8 +892,9 @@ int TRI_LoadStateReplicationApplier (TRI_vocbase_t* vocbase, } if (res == TRI_ERROR_NO_ERROR) { - // read the safeResumeTick - res |= ReadTick(json.get(), "safeResumeTick", &state->_safeResumeTick, true); + // read the safeResumeTick. note: this is an optional attribute + state->_safeResumeTick = 0; + ReadTick(json.get(), "safeResumeTick", &state->_safeResumeTick, true); } LOG_TRACE("replication state file read successfully"); diff --git a/arangod/VocBase/vocbase.cpp b/arangod/VocBase/vocbase.cpp index c1d7fe0364..86273eaacc 100644 --- a/arangod/VocBase/vocbase.cpp +++ b/arangod/VocBase/vocbase.cpp @@ -1486,8 +1486,9 @@ TRI_vocbase_t* TRI_OpenVocBase (TRI_server_t* server, vocbase->_replicationApplier = TRI_CreateReplicationApplier(server, vocbase); if (vocbase->_replicationApplier == nullptr) { - // TODO - LOG_FATAL_AND_EXIT("initializing replication applier for database '%s' failed", vocbase->_name); + LOG_FATAL_AND_EXIT("initializing replication applier for database '%s' failed: %s", + vocbase->_name, + TRI_last_error()); }