Fix version gap in old epoch's backup

When pull finished and message queue is empty, we should use end version as the
popVersion for backup files. Otherwise, there might be a version gap between
last message and end version.
This commit is contained in:
Jingyu Zhou 2020-03-03 21:04:50 -08:00
parent 70487cee1b
commit a0fb8ad5fc
1 changed files with 7 additions and 3 deletions

View File

@ -551,8 +551,6 @@ ACTOR Future<Void> uploadData(BackupData* self) {
// Even though messages is empty, we still want to advance popVersion.
if (!self->endVersion.present()) {
popVersion = std::max(popVersion, self->minKnownCommittedVersion);
} else if (self->pullFinished()) {
popVersion = self->endVersion.get();
}
} else {
for (const auto& message : self->messages) {
@ -561,7 +559,13 @@ ACTOR Future<Void> uploadData(BackupData* self) {
numMsg++;
}
}
if (numMsg > 0 || (popVersion > lastPopVersion && self->pulling)) {
if (self->messages.empty() && self->pullFinished()) {
popVersion = self->endVersion.get();
}
if (numMsg > 0 || (popVersion > lastPopVersion && self->pulling) || self->pullFinished()) {
TraceEvent("BackupWorkerSave", self->myId)
.detail("Version", popVersion)
.detail("MsgQ", self->messages.size());
// save an empty file for old epochs so that log file versions are continuous
wait(saveMutationsToFile(self, popVersion, numMsg));
self->messages.erase(self->messages.begin(), self->messages.begin() + numMsg);