8000 ARANGODB_UPGRADE_DURING_RESTORE env variable. (#10385) · arangodb/arangodb@b318ca8 · GitHub
[go: up one dir, main page]

Skip to content

Commit b318ca8

Browse files
authored
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.
1 parent 2faa44d commit b318ca8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

arangod/RestServer/UpgradeFeature.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,36 @@ void UpgradeFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
7474
arangodb::options::makeFlags(arangodb::options::Flags::Hidden));
7575
}
7676

77+
/// @brief This external is buried in RestServer/arangod.cpp.
78+
/// Used to perform one last action upon shutdown.
79+
extern std::function<int()> * restartAction;
80+
81+
#ifndef _WIN32
82+
static std::string const UPGRADE_ENV = "ARANGODB_UPGRADE_DURING_RESTORE";
83+
84+
static int upgradeRestart() {
85+
unsetenv(UPGRADE_ENV.c_str());
86+
return 0;
87+
}
88+
#endif
89+
7790
void UpgradeFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
91+
#ifndef _WIN32
92+
// The following environment variable is another way to run a database
93+
// upgrade. If the environment variable is set, the system does a database
94+
// upgrade and then restarts itself without the environment variable.
95+
// This is used in hotbackup if a restore to a backup happens which is from
96+
// an older database version. The restore process sets the environment
97+
// variable at runtime and then does a restore. After the restart (with
98+
// the old data) the database upgrade is run and another restart is
99+
// happening afterwards with the environment variable being cleared.
100+
char* upgrade = getenv(UPGRADE_ENV.c_str());
101+
if (upgrade != nullptr) {
102+
_upgrade = true;
103+
restartAction = new std::function<int()>();
104+
*restartAction = upgradeRestart;
105+
}
106+
#endif
78107
if (_upgrade && !_upgradeCheck) {
79108
LOG_TOPIC("47698", FATAL, arangodb::Logger::FIXME)
80109
<< "cannot specify both '--database.auto-upgrade true' and "

0 commit comments

Comments
 (0)
0