Download a fossil directly instead of turning it back to a chunk first

This is to avoid the read-after-rename consistency issue where the effect
of renaming may not be observed by the subsequent attempt to download the
just renamed chunk.
This commit is contained in:
Gilbert Chen
2021-10-08 14:04:56 -04:00
parent e43e848d47
commit cacf6618d2

View File

@@ -427,17 +427,10 @@ func (downloader *ChunkDownloader) Download(threadIndex int, task ChunkDownloadT
return false return false
} }
// We can't download the fossil directly. We have to turn it back into a regular chunk and try // Don't try to resurrect the fossil as we did before. This is to avoid the potential read-after-rename
// downloading again. // consistency issue. Instead, download the fossil directly; resurrection should be taken care of later.
err = downloader.storage.MoveFile(threadIndex, fossilPath, chunkPath) chunkPath = fossilPath
if err != nil { LOG_WARN("DOWNLOAD_FOSSIL", "Chunk %s is a fossil", chunkID)
completeFailedChunk(chunk)
LOG_WERROR(downloader.allowFailures, "DOWNLOAD_CHUNK", "Failed to resurrect chunk %s: %v", chunkID, err)
return false
}
LOG_WARN("DOWNLOAD_RESURRECT", "Fossil %s has been resurrected", chunkID)
continue
} }
err = downloader.storage.DownloadFile(threadIndex, chunkPath, chunk) err = downloader.storage.DownloadFile(threadIndex, chunkPath, chunk)