8000 Minor fixes for hotbackup before 3.6 release. by neunhoef · Pull Request #10458 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Minor fixes for hotbackup before 3.6 release. #10458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion arangod/GeneralServer/VstCommTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@ void VstCommTask<T>::doWrite() {
} else {
thisPtr->doWrite(); // write next one
}
rsp->stat->release();
if (rsp->stat != nullptr) {
rsp->stat->release();
}
});
break; // done
}
Expand Down
51 changes: 16 additions & 35 deletions arangosh/Backup/BackupFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,13 @@ arangodb::Result executeCreate(arangodb::httpclient::SimpleHttpClient& client,
{
VPackObjectBuilder guard(&bodyBuilder);
bodyBuilder.add("timeout", VPackValue(options.maxWaitForLock));
bodyBuilder.add("allowInconsistent", VPackValue(options.force));
bodyBuilder.add("allowInconsistent", VPackValue(options.allowInconsistent));
if (!options.label.empty()) {
bodyBuilder.add("label", VPackValue(options.label));
}
if (options.abortTransactionsIfNeeded) {
bodyBuilder.add("force", VPackValue(true));
}
}
std::string const body = bodyBuilder.slice().toJson();
std::unique_ptr<arangodb::httpclient::SimpleHttpResult> response(
Expand Down Expand Up @@ -361,8 +364,7 @@ arangodb::Result executeRestore(arangodb::httpclient::SimpleHttpClient& client,
{
VPackObjectBuilder guard(&bodyBuilder);
bodyBuilder.add("id", VPackValue(options.identifier));
bodyBuilder.add("saveCurrent", VPackValue(options.saveCurrent));
if (options.force) {
if (options.ignoreVersion) {
bodyBuilder.add("ignoreVersion", VPackValue(true));
}
}
Expand All @@ -383,33 +385,6 @@ arangodb::Result executeRestore(arangodb::httpclient::SimpleHttpClient& client,
return result;
}

if (options.saveCurrent) {
VPackSlice const resBody = parsedBody->slice();
if (!resBody.isObject()) {
result.reset(TRI_ERROR_INTERNAL, "expected response to be an object");
return result;
}
TRI_ASSERT(resBody.isObject());

VPackSlice const resultObject = resBody.get("result");
if (!resultObject.isObject()) {
result.reset(TRI_ERROR_INTERNAL, "expected 'result' to be an object");
return result;
}
TRI_ASSERT(resultObject.isObject());

VPackSlice const previous = resultObject.get("previous");
if (!previous.isString()) {
result.reset(TRI_ERROR_INTERNAL, "expected previous to be a string");
return result;
}
TRI_ASSERT(previous.isString());

LOG_TOPIC("08c95", INFO, arangodb::Logger::BACKUP)
<< "current state was saved as backup with identifier '"
<< previous.copyString() << "'";
}

LOG_TOPIC("b6d4c", INFO, arangodb::Logger::BACKUP)
<< "Successfully restored '" << options.identifier << "'";

Expand Down Expand Up @@ -706,7 +681,12 @@ void BackupFeature::collectOptions(std::shared_ptr<options::ProgramOptions> opti
options->addOption("--allow-inconsistent",
"whether to attempt to continue in face of errors; "
"may result in inconsistent backup state (create operation)",
new BooleanParameter(&_options.force));
new BooleanParameter(&_options.allowInconsistent));

options->addOption("--ignore-version",
"ignore stored version of a backup"
"restore may not work if version mismatch (restore operation)",
new BooleanParameter(&_options.ignoreVersion));

options->addOption("--identifier",
"a unique identifier for a backup "
Expand Down Expand Up @@ -734,10 +714,6 @@ void BackupFeature::collectOptions(std::shared_ptr<options::ProgramOptions> opti
"result of the restore request (restore operation)",
new DoubleParameter(&_options.maxWaitForRestart));

options->addOption("--save-current",
"whether to save the current state as a backup before "
"restoring to another state (restore operation)",
new BooleanParameter(&_options.saveCurrent));
#ifdef USE_ENTERPRISE
options->addOption("--status-id",
"returns the status of a transfer process "
Expand All @@ -758,6 +734,11 @@ void BackupFeature::collectOptions(std::shared_ptr<options::ProgramOptions> opti
"abort transfer with given status-id "
"(upload/download operation)",
new BooleanParameter(&_options.abort));

options->addOption("--force",
"abort transactions if needed to ensure a consistent snapshot"
"(create operation)",
new BooleanParameter(&_options.abortTransactionsIfNeeded));
#endif
/*
options->addSection(
Expand Down
5 changes: 3 additions & 2 deletions arangosh/Backup/BackupFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class BackupFeature : public application_features::ApplicationFeature {

public:
struct Options {
bool force = false;
bool allowInconsistent = false;
std::string identifier = "";
std::string label = "";
std::string statusId = "";
Expand All @@ -65,8 +65,9 @@ class BackupFeature : public application_features::ApplicationFeature {
double maxWaitForLock = 60.0;
double maxWaitForRestart = 0.0;
std::string operation = "list";
bool saveCurrent = false;
bool abort = false;
bool abortTransactionsIfNeeded = false;
bool ignoreVersion = false;
};

private:
Expand Down
12 changes: 8 additions & 4 deletions lib/Basics/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ int TRI_RemoveDirectoryDeterministic(char const* filename) {

std::string TRI_Dirname(std::string const& path) {
size_t n = path.size();

if (n == 0) {
// "" => "."
return std::string(".");
Expand Down Expand Up @@ -766,6 +766,10 @@ std::string TRI_Basename(char const* path) {
}
}

std::string TRI_Basename(std::string const& path) {
return TRI_Basename(path.c_str());
}

////////////////////////////////////////////////////////////////////////////////
/// @brief returns a list of files in path
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1124,7 +1128,7 @@ bool TRI_ProcessFile(char const* filename,
char* TRI_SlurpGzipFile(char const* filename, size_t* length) {
TRI_set_errno(TRI_ERROR_NO_ERROR);
gzFile gzFd = gzopen(filename,"rb");
auto fdGuard = arangodb::scopeGuard([&gzFd]() {
auto fdGuard = arangodb::scopeGuard([&gzFd]() {
if (nullptr != gzFd) {
gzclose(gzFd);
}
Expand Down Expand Up @@ -1181,7 +1185,7 @@ char* TRI_SlurpDecryptFile(EncryptionFeature& encryptionFeature, char const* fil
TRI_set_errno(TRI_ERROR_NO_ERROR);

encryptionFeature.setKeyFile(keyfile);
auto keyGuard = arangodb::scopeGuard([&encryptionFeature]() {
auto keyGuard = arangodb::scopeGuard([&encryptionFeature]() {
encryptionFeature.clearKey();
});

Expand Down Expand Up @@ -2320,7 +2324,7 @@ std::string TRI_GetTempPath() {
// no --temp.path was specified
// fill template and create directory
tries = 9;

// create base directories of the new directory (but ignore any failures
// if they already exist. if this fails, the following mkDTemp will either
// succeed or fail and return an error
Expand Down
6 changes: 6 additions & 0 deletions lib/Basics/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ std::string TRI_Dirname(std::string const& path);

std::string TRI_Basename(char const* path);

////////////////////////////////////////////////////////////////////////////////
/// @brief extracts the basename
////////////////////////////////////////////////////////////////////////////////

std::string TRI_Basename(std::string const& path);

////////////////////////////////////////////////////////////////////////////////
/// @brief returns a list of files in path
////////////////////////////////////////////////////////////////////////////////
Expand Down
0