Merge pull request #2685 from jzhou77/backup-fix

Fix key_not_found error due to deleted BackupConfig
This commit is contained in:
Meng Xu 2020-02-15 21:45:01 -08:00 committed by GitHub
commit b81e2e0e1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -89,7 +89,7 @@ struct BackupData {
BackupData* self = nullptr;
Version startVersion = invalidVersion;
Version lastSavedVersion = invalidVersion;
Future<Reference<IBackupContainer>> container;
Future<Optional<Reference<IBackupContainer>>> container;
Future<Optional<std::vector<KeyRange>>> ranges; // Key ranges of this backup
bool allWorkerStarted = false; // Only worker with Tag(-2,0) uses & sets this field
bool stopped = false; // Is the backup stopped?
@ -188,7 +188,7 @@ struct BackupData {
// Open the container and get key ranges
BackupConfig config(uid);
inserted.first->second.container = config.backupContainer().getOrThrow(cx);
inserted.first->second.container = config.backupContainer().get(cx);
inserted.first->second.ranges = config.backupRanges().get(cx);
} else {
stopList.erase(uid);
@ -395,19 +395,25 @@ ACTOR Future<Void> saveMutationsToFile(BackupData* self, Version popVersion, int
for (auto it = self->backups.begin(); it != self->backups.end();) {
if (!it->second.isRunning()) {
if (it->second.stopped) {
TraceEvent("BackupWorkerRemoveStoppedContainer", self->myId).detail("BackupId", it->first);
it = self->backups.erase(it);
} else {
it++;
}
continue;
}
if (!it->second.container.get().present()) {
TraceEvent("BackupWorkerNoContainer", self->myId).detail("BackupId", it->first);
it = self->backups.erase(it);
continue;
}
const int index = logFileFutures.size();
activeUids.insert(it->first);
self->insertRanges(keyRangeMap, it->second.ranges.get(), index);
if (it->second.lastSavedVersion == invalidVersion) {
it->second.lastSavedVersion = self->messages[0].getVersion();
}
logFileFutures.push_back(it->second.container.get()->writeTaggedLogFile(
logFileFutures.push_back(it->second.container.get().get()->writeTaggedLogFile(
it->second.lastSavedVersion, popVersion + 1, blockSize, self->tag.id));
it++;
}