mirror of https://gitee.com/bigwinds/arangodb
ARANGODB_UPGRADE_DURING_RESTORE env variable. (#10385)
* ARANGODB_UPGRADE_DURING_RESTORE env variable. If this is set during startup, a database upgrade is performed and an automatic restart (with the same process ID) is happening. * Windows compatibility. * Deactivate code for Windows. Back to unsetenv.
This commit is contained in:
parent
2faa44dac4
commit
b318ca8084
|
@ -74,7 +74,36 @@ void UpgradeFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
arangodb::options::makeFlags(arangodb::options::Flags::Hidden));
|
arangodb::options::makeFlags(arangodb::options::Flags::Hidden));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief This external is buried in RestServer/arangod.cpp.
|
||||||
|
/// Used to perform one last action upon shutdown.
|
||||||
|
extern std::function<int()> * restartAction;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
static std::string const UPGRADE_ENV = "ARANGODB_UPGRADE_DURING_RESTORE";
|
||||||
|
|
||||||
|
static int upgradeRestart() {
|
||||||
|
unsetenv(UPGRADE_ENV.c_str());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void UpgradeFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
|
void UpgradeFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
|
#ifndef _WIN32
|
||||||
|
// The following environment variable is another way to run a database
|
||||||
|
// upgrade. If the environment variable is set, the system does a database
|
||||||
|
// upgrade and then restarts itself without the environment variable.
|
||||||
|
// This is used in hotbackup if a restore to a backup happens which is from
|
||||||
|
// an older database version. The restore process sets the environment
|
||||||
|
// variable at runtime and then does a restore. After the restart (with
|
||||||
|
// the old data) the database upgrade is run and another restart is
|
||||||
|
// happening afterwards with the environment variable being cleared.
|
||||||
|
char* upgrade = getenv(UPGRADE_ENV.c_str());
|
||||||
|
if (upgrade != nullptr) {
|
||||||
|
_upgrade = true;
|
||||||
|
restartAction = new std::function<int()>();
|
||||||
|
*restartAction = upgradeRestart;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (_upgrade && !_upgradeCheck) {
|
if (_upgrade && !_upgradeCheck) {
|
||||||
LOG_TOPIC("47698", FATAL, arangodb::Logger::FIXME)
|
LOG_TOPIC("47698", FATAL, arangodb::Logger::FIXME)
|
||||||
<< "cannot specify both '--database.auto-upgrade true' and "
|
<< "cannot specify both '--database.auto-upgrade true' and "
|
||||||
|
|
Loading…
Reference in New Issue