Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4809,6 +4809,14 @@ private boolean localDirectoryContains(Directory localDirectory, String file, lo
return true;
} else {
logger.warn("Checksum mismatch between local and remote segment file: {}, will override local file", file);
// If there is a checksum mismatch and we are not serving reads it is safe to go ahead and delete the file now.
// Outside of engine resets this method will be invoked during recovery so this is safe.
if (isReadAllowed() == false) {
localDirectory.deleteFile(file);
} else {
// segment conflict with remote store while the shard is serving reads.
failShard("Local copy of segment " + file + " has a different checksum than the version in remote store", null);
}
}
} catch (NoSuchFileException | FileNotFoundException e) {
logger.debug("File {} does not exist in local FS, downloading from remote store", file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,10 @@ private void updateLocalSizeMapAndTracker(Collection<String> segmentFiles) {
private void updateFinalStatusInSegmentTracker(boolean uploadStatus, long bytesBeforeUpload, long startTimeInNS) {
if (uploadStatus) {
long bytesUploaded = segmentTracker.getUploadBytesSucceeded() - bytesBeforeUpload;
long timeTakenInMS = (System.nanoTime() - startTimeInNS) / 1_000_000L;

long timeTakenInMS = TimeValue.nsecToMSec(System.nanoTime() - startTimeInNS);
segmentTracker.incrementTotalUploadsSucceeded();
segmentTracker.addUploadBytes(bytesUploaded);
segmentTracker.addUploadBytesPerSec((bytesUploaded * 1_000L) / timeTakenInMS);
segmentTracker.addUploadBytesPerSec((bytesUploaded * 1_000L) / Math.max(1, timeTakenInMS));
segmentTracker.addUploadTimeMs(timeTakenInMS);
} else {
segmentTracker.incrementTotalUploadsFailed();
Expand Down