Rare bug fix. It turns out that backup log files must be written with unique names, otherwise a re-written >1 block log file overwritten after a restore has begun could read some blocks from before the rewrite and some blocks after, but due to random content ordering this would be incorrect and produce a corrupt restore. This bug is very rare because restore would detect an error unless the rewritten log file has exactly same size as the original file, but this is unlikely because the random content order affects block padding and therefore usable content bytes per block.

This commit is contained in:
Stephen Atherton 2018-01-02 23:38:01 -08:00
parent 371dee70e6
commit 96c479dc71
1 changed files with 2 additions and 2 deletions

View File

@ -142,7 +142,7 @@ public:
}
Future<Reference<IBackupFile>> writeLogFile(Version beginVersion, Version endVersion, int blockSize) {
return writeFile(format("logs/%s/log,%lld,%lld,%d", logVersionFolderString(beginVersion).c_str(), beginVersion, endVersion, blockSize));
return writeFile(format("logs/%s/log,%lld,%lld,%s,%d", logVersionFolderString(beginVersion).c_str(), beginVersion, endVersion, g_random->randomUniqueID().toString().c_str(), blockSize));
}
Future<Reference<IBackupFile>> writeRangeFile(Version version, int blockSize) {
@ -166,7 +166,7 @@ public:
f.fileName = path;
f.fileSize = size;
int len;
if(sscanf(name.c_str(), "log,%lld,%lld,%u%n", &f.beginVersion, &f.endVersion, &f.blockSize, &len) == 3 && len == name.size())
if(sscanf(name.c_str(), "log,%lld,%lld,%*[^,],%u%n", &f.beginVersion, &f.endVersion, &f.blockSize, &len) == 3 && len == name.size())
return f;
throw restore_unknown_file_type();
}