8000 Minor fixes for hotbackup before 3.6 release. (#10458) · arangodb/arangodb@315a7ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 315a7ba

Browse files
authored
Minor fixes for hotbackup before 3.6 release. (#10458)
* TRI_Basename finally with std::string const& parameter overload. I hate .c_str() * Fix statistics bug. * Lose saveCurrent in client tool. * Sort out options of arangobackup.
1 parent b0db98c commit 315a7ba

File tree

5 files changed

+36
-42
lines changed

5 files changed

+36
-42
lines changed

arangod/GeneralServer/VstCommTask.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ void VstCommTask<T>::doWrite() {
379379
} else {
380380
thisPtr->doWrite(); // write next one
381381
}
382-
rsp->stat->release();
382+
if (rsp->stat != nullptr) {
383+
rsp->stat->release();
384+
}
383385
});
384386
break; // done
385387
}

arangosh/Backup/BackupFeature.cpp

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,13 @@ arangodb::Result executeCreate(arangodb::httpclient::SimpleHttpClient& client,
277277
{
278278
VPackObjectBuilder guard(&bodyBuilder);
279279
bodyBuilder.add("timeout", VPackValue(options.maxWaitForLock));
280-
bodyBuilder.add("allowInconsistent", VPackValue(options.force));
280+
bodyBuilder.add("allowInconsistent", VPackValue(options.allowInconsistent));
281281
if (!options.label.empty()) {
282282
bodyBuilder.add("label", VPackValue(options.label));
283283
}
284+
if (options.abortTransactionsIfNeeded) {
285+
bodyBuilder.add("force", VPackValue(true));
286+
}
284287
}
285288
std::string const body = bodyBuilder.slice().toJson();
286289
std::unique_ptr<arangodb::httpclient::SimpleHttpResult> response(
@@ -361,8 +364,7 @@ arangodb::Result executeRestore(arangodb::httpclient::SimpleHttpClient& client,
361364
{
362365
VPackObjectBuilder guard(&bodyBuilder);
363366
bodyBuilder.add("id", VPackValue(options.identifier));
364-
bodyBuilder.add("saveCurrent", VPackValue(options.saveCurrent));
365-
if (options.force) {
367+
if (options.ignoreVersion) {
366368
bodyBuilder.add("ignoreVersion", VPackValue(true));
367369
}
368370
}
@@ -383,33 +385,6 @@ arangodb::Result executeRestore(arangodb::httpclient::SimpleHttpClient& client,
383385
return result;
384386
}
385387

386-
if (options.saveCurrent) {
387-
VPackSlice const resBody = parsedBody->slice();
388-
if (!resBody.isObject()) {
389-
result.reset(TRI_ERROR_INTERNAL, "expected response to be an object");
390-
return result;
391-
}
392-
TRI_ASSERT(resBody.isObject());
393-
394-
VPackSlice const resultObject = resBody.get("result");
395-
if (!resultObject.isObject()) {
396-
result.reset(TRI_ERROR_INTERNAL, "expected 'result' to be an object");
397-
return result;
398-
}
399-
TRI_ASSERT(resultObject.isObject());
400-
401-
VPackSlice const previous = resultObject.get("previous");
402-
if (!previous.isString()) {
403-
result.reset(TRI_ERROR_INTERNAL, "expected previous to be a string");
404-
return result;
405-
}
406-
TRI_ASSERT(previous.isString());
407-
408-
LOG_TOPIC("08c95", INFO, arangodb::Logger::BACKUP)
409-
<< "current state was saved as backup with identifier '"
410-
<< previous.copyString() << "'";
411-
}
412-
413388
LOG_TOPIC("b6d4c", INFO, arangodb::Logger::BACKUP)
414389
<< "Successfully restored '" << options.identifier << "'";
415390

@@ -706,7 +681,12 @@ void BackupFeature::collectOptions(std::shared_ptr<options::ProgramOptions> opti
706681
options->addOption("--allow-inconsistent",
707682
"whether to attempt to continue in face of errors; "
708683
"may result in inconsistent backup state (create operation)",
709-
new BooleanParameter(&_options.force));
684+
new BooleanParameter(&_options.allowInconsistent));
685+
686+
options->addOption("--ignore-version",
687+
"ignore stored version of a backup"
688+
"restore may not work if version mismatch (restore operation)",
689+
new BooleanParameter(&_options.ignoreVersion));
710690

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

737-
options->addOption("--save-current",
738-
"whether to save the current state as a backup before "
739-
"restoring to another state (restore operation)",
740-
new BooleanParameter(&_options.saveCurrent));
741717
#ifdef USE_ENTERPRISE
742718
options->addOption("--status-id",
743719
"returns the status of a transfer process "
@@ -758,6 +734,11 @@ void BackupFeature::collectOptions(std::shared_ptr<options::ProgramOptions> opti
758734
"abort transfer with given status-id "
759735
"(upload/download operation)",
760736
new BooleanParameter(&_options.abort));
737+
738+
options->addOption("--force",
739+
"abort transactions if needed to ensure a consistent snapshot"
740+
"(create operation)",
741+
new BooleanParameter(&_options.abortTransactionsIfNeeded));
761742
#endif
762743
/*
763744
options->addSection(

arangosh/Backup/BackupFeature.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class BackupFeature : public application_features::ApplicationFeature {
5656

5757
public:
5858
struct Options {
59-
bool force = false;
59+
bool allowInconsistent = false;
6060
std::string identifier = "";
6161
std::string label = "";
6262
std::string statusId = "";
@@ -65,8 +65,9 @@ class BackupFeature : public application_features::ApplicationFeature {
6565
double maxWaitForLock = 60.0;
6666
double maxWaitForRestart = 0.0;
6767
std::string operation = "list";
68-
bool saveCurrent = false;
6968
bool abort = false;
69+
bool abortTransactionsIfNeeded = false;
70+
bool ignoreVersion = false;
7071
};
7172

7273
private:

lib/Basics/files.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ int TRI_RemoveDirectoryDeterministic(char const* filename) {
684684

685685
std::string TRI_Dirname(std::string const& path) {
686686
size_t n = path.size();
687-
687+
688688
if (n == 0) {
689689
// "" => "."
690690
return std::string(".");
@@ -766,6 +766,10 @@ std::string TRI_Basename(char const* path) {
766766
}
767767
}
768768

769+
std::string TRI_Basename(std::string const& path) {
770+
return TRI_Basename(path.c_str());
771+
}
772+
769773
////////////////////////////////////////////////////////////////////////////////
770774
/// @brief returns a list of files in path
771775
////////////////////////////////////////////////////////////////////////////////
@@ -1124,7 +1128,7 @@ bool TRI_ProcessFile(char const* filename,
11241128
char* TRI_SlurpGzipFile(char const* filename, size_t* length) {
11251129
TRI_set_errno(TRI_ERROR_NO_ERROR);
11261130
gzFile gzFd = gzopen(filename,"rb");
1127-
auto fdGuard = arangodb::scopeGuard([&gzFd]() {
1131+
auto fdGuard = arangodb::scopeGuard([&gzFd]() {
11281132
if (nullptr != gzFd) {
11291133
gzclose(gzFd);
11301134
}
@@ -1181,7 +1185,7 @@ char* TRI_SlurpDecryptFile(EncryptionFeature& encryptionFeature, char const* fil
11811185
TRI_set_errno(TRI_ERROR_NO_ERROR);
11821186

11831187
encryptionFeature.setKeyFile(keyfile);
1184-
auto keyGuard = arangodb::scopeGuard([&encryptionFeature]() {
1188+
auto keyGuard = arangodb::scopeGuard([&encryptionFeature]() {
11851189
encryptionFeature.clearKey();
11861190
});
11871191

@@ -2320,7 +2324,7 @@ std::string TRI_GetTempPath() {
23202324
// no --temp.path was specified
23212325
// fill template and create directory
23222326
tries = 9;
2323-
2327+
23242328
// create base directories of the new directory (but ignore any failures
23252329
// if they already exist. if this fails, the following mkDTemp will either
23262330
// succeed or fail and return an error

lib/Basics/files.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ std::string TRI_Dirname(std::string const& path);
144144

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

147+
////////////////////////////////////////////////////////////////////////////////
148+
/// @brief extracts the basename
149+
////////////////////////////////////////////////////////////////////////////////
150+
151+
std::string TRI_Basename(std::string const& path);
152+
147153
////////////////////////////////////////////////////////////////////////////////
148154
/// @brief returns a list of files in path
149155
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)
0