MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / restore_partials

Function restore_partials

tools/comdb2ar/deserialise.cpp:1027–1193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1025}
1026
1027void restore_partials(
1028 const std::string &lrlpath, const std::string& comdb2_task, bool run_full_recovery, bool do_direct_io, bool dryrun
1029// On stdio is a tarball containing a partial file. Apply it against the current
1030// set of database files in the directory given by the lrl file.
1031) {
1032 std::string dbname;
1033 std::string dbdir;
1034 std::list<std::string> support_files;
1035 std::set<std::string> table_names;
1036 std::set<std::string> queue_names;
1037 bool nonames;
1038 bool has_cluster_info;
1039 tar_block_header hdr;
1040 bool is_manifest = false;
1041 unsigned long long filesize;
1042 uint8_t zeroblock[512] = {0};
1043 int64_t manifest_size;
1044
1045 // settings encoded in manifest
1046 std::map<std::string, std::pair<FileInfo, std::vector<uint32_t>>> updated_files;
1047 std::map<std::string, FileInfo> new_files;
1048 std::set<std::string> deleted_files;
1049 std::vector<std::string> file_order;
1050 std::vector<std::string> options;
1051 std::string manifest_sha;
1052
1053 parse_lrl_file(lrlpath, &dbname, &dbdir, &support_files, &table_names, &queue_names, &nonames, &has_cluster_info);
1054
1055 if (!dbdir.empty() && !dbname.empty()) {
1056 nonames = check_usenames(dbname, dbdir, nonames);
1057 }
1058
1059 // The first thing we need to do is to delete all the logs - we
1060 // don't want recovery run on partial logs
1061 std::string logpath;
1062 if (nonames)
1063 logpath = dbdir + "/logs";
1064 else
1065 logpath = dbdir + "/" + dbname + ".txn";
1066
1067 std::cout << "start restore, datapath " << dbdir << " logpath " << logpath << std::endl;
1068
1069 std::list<std::string> logfiles;
1070 listdir(logfiles, logpath);
1071 for (std::list<std::string>::const_iterator it = logfiles.begin();
1072 it != logfiles.end(); ++it) {
1073 if (it->compare(0, 4, "log.") == 0 && it->length() == 14) {
1074 std::string logfile = logpath + "/" + *it;
1075 unlink(logfile.c_str());
1076 }
1077 }
1078
1079
1080 for (;;) {
1081 ssize_t rb = readall(0, &hdr, sizeof(hdr));
1082 if (rb != sizeof(hdr)) {
1083 std::ostringstream ss;
1084 ss << "huh? read " << rb << "bytes";

Callers 1

mainFunction · 0.85

Calls 12

parse_lrl_fileFunction · 0.85
check_usenamesFunction · 0.85
listdirFunction · 0.85
readallFunction · 0.85
ErrorClass · 0.85
read_octal_ullFunction · 0.85
read_incr_manifestFunction · 0.85
process_incr_manifestFunction · 0.85
clear_log_folderFunction · 0.85
unpack_incr_dataFunction · 0.85
deserialize_fileFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected