Write mutation log type as a backup property

This can solve the problem when listing log files returns empty results.
This commit is contained in:
Jingyu Zhou 2020-04-08 22:52:23 -07:00
parent 4d06e837dc
commit db2cef844b
2 changed files with 20 additions and 8 deletions

View File

@ -723,10 +723,12 @@ public:
state Optional<Version> metaLogEnd; state Optional<Version> metaLogEnd;
state Optional<Version> metaExpiredEnd; state Optional<Version> metaExpiredEnd;
state Optional<Version> metaUnreliableEnd; state Optional<Version> metaUnreliableEnd;
state Optional<Version> metaLogType;
std::vector<Future<Void>> metaReads; std::vector<Future<Void>> metaReads;
metaReads.push_back(store(metaExpiredEnd, bc->expiredEndVersion().get())); metaReads.push_back(store(metaExpiredEnd, bc->expiredEndVersion().get()));
metaReads.push_back(store(metaUnreliableEnd, bc->unreliableEndVersion().get())); metaReads.push_back(store(metaUnreliableEnd, bc->unreliableEndVersion().get()));
metaReads.push_back(store(metaLogType, bc->logType().get()));
// Only read log begin/end versions if not doing a deep scan, otherwise scan files and recalculate them. // Only read log begin/end versions if not doing a deep scan, otherwise scan files and recalculate them.
if(!deepScan) { if(!deepScan) {
@ -737,12 +739,13 @@ public:
wait(waitForAll(metaReads)); wait(waitForAll(metaReads));
TraceEvent("BackupContainerDescribe2") TraceEvent("BackupContainerDescribe2")
.detail("URL", bc->getURL()) .detail("URL", bc->getURL())
.detail("LogStartVersionOverride", logStartVersionOverride) .detail("LogStartVersionOverride", logStartVersionOverride)
.detail("ExpiredEndVersion", metaExpiredEnd.orDefault(invalidVersion)) .detail("ExpiredEndVersion", metaExpiredEnd.orDefault(invalidVersion))
.detail("UnreliableEndVersion", metaUnreliableEnd.orDefault(invalidVersion)) .detail("UnreliableEndVersion", metaUnreliableEnd.orDefault(invalidVersion))
.detail("LogBeginVersion", metaLogBegin.orDefault(invalidVersion)) .detail("LogBeginVersion", metaLogBegin.orDefault(invalidVersion))
.detail("LogEndVersion", metaLogEnd.orDefault(invalidVersion)); .detail("LogEndVersion", metaLogEnd.orDefault(invalidVersion))
.detail("LogType", metaLogType.orDefault(-1));
// If the logStartVersionOverride is positive (not relative) then ensure that unreliableEndVersion is equal or greater // If the logStartVersionOverride is positive (not relative) then ensure that unreliableEndVersion is equal or greater
if(logStartVersionOverride != invalidVersion && metaUnreliableEnd.orDefault(invalidVersion) < logStartVersionOverride) { if(logStartVersionOverride != invalidVersion && metaUnreliableEnd.orDefault(invalidVersion) < logStartVersionOverride) {
@ -810,7 +813,7 @@ public:
desc.partitioned = true; desc.partitioned = true;
logs.swap(plogs); logs.swap(plogs);
} else { } else {
desc.partitioned = false; desc.partitioned = metaLogType.present() && metaLogType.get() == PARTITIONED_MUTATION_LOG;
} }
// List logs in version order so log continuity can be analyzed // List logs in version order so log continuity can be analyzed
@ -857,6 +860,11 @@ public:
updates = updates && bc->logEndVersion().set(desc.contiguousLogEnd.get()); updates = updates && bc->logEndVersion().set(desc.contiguousLogEnd.get());
} }
if (!metaLogType.present()) {
updates = updates && bc->logType().set(desc.partitioned ? PARTITIONED_MUTATION_LOG
: NON_PARTITIONED_MUTATION_LOG);
}
wait(updates); wait(updates);
} catch(Error &e) { } catch(Error &e) {
if(e.code() == error_code_actor_cancelled) if(e.code() == error_code_actor_cancelled)
@ -1384,6 +1392,11 @@ public:
VersionProperty expiredEndVersion() { return {Reference<BackupContainerFileSystem>::addRef(this), "expired_end_version"}; } VersionProperty expiredEndVersion() { return {Reference<BackupContainerFileSystem>::addRef(this), "expired_end_version"}; }
VersionProperty unreliableEndVersion() { return {Reference<BackupContainerFileSystem>::addRef(this), "unreliable_end_version"}; } VersionProperty unreliableEndVersion() { return {Reference<BackupContainerFileSystem>::addRef(this), "unreliable_end_version"}; }
// Backup log types
const static Version NON_PARTITIONED_MUTATION_LOG = 0;
const static Version PARTITIONED_MUTATION_LOG = 1;
VersionProperty logType() { return { Reference<BackupContainerFileSystem>::addRef(this), "mutation_log_type" }; }
ACTOR static Future<Void> writeVersionProperty(Reference<BackupContainerFileSystem> bc, std::string path, Version v) { ACTOR static Future<Void> writeVersionProperty(Reference<BackupContainerFileSystem> bc, std::string path, Version v) {
try { try {
state Reference<IBackupFile> f = wait(bc->writeFile(path)); state Reference<IBackupFile> f = wait(bc->writeFile(path));

View File

@ -218,7 +218,6 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
if(!fdesc.isError()) { if(!fdesc.isError()) {
state BackupDescription desc = fdesc.get(); state BackupDescription desc = fdesc.get();
ASSERT(self->usePartitionedLogs == desc.partitioned);
wait(desc.resolveVersionTimes(cx)); wait(desc.resolveVersionTimes(cx));
printf("BackupDescription:\n%s\n", desc.toString().c_str()); printf("BackupDescription:\n%s\n", desc.toString().c_str());
restorable = desc.maxRestorableVersion.present(); restorable = desc.maxRestorableVersion.present();