mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 01:19:02 +00:00
Snapshot/Restore: blob store shouldn't try deleting the write.lock file at the end of the restore process
Since we are creating write.lock earlier now, blob store shouldn't attempt deleting this file during clean up at the end of the restore process. The file is locked and the blog store doesn't succeed, but it generates a lot of useless warnings "failed to delete file [write.lock] during snapshot cleanup". Closes #11517
This commit is contained in:
parent
02c9c8998e
commit
1d02212b1c
@ -19,15 +19,10 @@
|
||||
|
||||
package org.elasticsearch.index.snapshots.blobstore;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import org.apache.lucene.index.CorruptIndexException;
|
||||
import org.apache.lucene.index.IndexFormatTooNewException;
|
||||
import org.apache.lucene.index.IndexFormatTooOldException;
|
||||
import org.apache.lucene.index.SegmentInfos;
|
||||
import org.apache.lucene.index.*;
|
||||
import org.apache.lucene.store.IOContext;
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
import org.apache.lucene.store.IndexOutput;
|
||||
@ -902,13 +897,14 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements
|
||||
/// now, go over and clean files that are in the store, but were not in the snapshot
|
||||
try {
|
||||
for (String storeFile : store.directory().listAll()) {
|
||||
if (!Store.isChecksum(storeFile) && !snapshotFiles.containPhysicalIndexFile(storeFile)) {
|
||||
try {
|
||||
store.deleteQuiet("restore", storeFile);
|
||||
store.directory().deleteFile(storeFile);
|
||||
} catch (IOException e) {
|
||||
logger.warn("[{}] failed to delete file [{}] during snapshot cleanup", snapshotId, storeFile);
|
||||
}
|
||||
if (Store.isAutogenerated(storeFile) || snapshotFiles.containPhysicalIndexFile(storeFile)) {
|
||||
continue; //skip write.lock, checksum files and files that exist in the snapshot
|
||||
}
|
||||
try {
|
||||
store.deleteQuiet("restore", storeFile);
|
||||
store.directory().deleteFile(storeFile);
|
||||
} catch (IOException e) {
|
||||
logger.warn("[{}] failed to delete file [{}] during snapshot cleanup", snapshotId, storeFile);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -586,7 +586,7 @@ public class Store extends AbstractIndexShardComponent implements Closeable, Ref
|
||||
try (Lock writeLock = Lucene.acquireWriteLock(directory)) {
|
||||
final StoreDirectory dir = directory;
|
||||
for (String existingFile : dir.listAll()) {
|
||||
if (existingFile.equals(IndexWriter.WRITE_LOCK_NAME) || Store.isChecksum(existingFile) || sourceMetaData.contains(existingFile)) {
|
||||
if (Store.isAutogenerated(existingFile) || sourceMetaData.contains(existingFile)) {
|
||||
continue; // don't delete snapshot file, or the checksums file (note, this is extra protection since the Store won't delete checksum)
|
||||
}
|
||||
try {
|
||||
@ -1206,11 +1206,19 @@ public class Store extends AbstractIndexShardComponent implements Closeable, Ref
|
||||
|
||||
public static final String CHECKSUMS_PREFIX = "_checksums-";
|
||||
|
||||
public static final boolean isChecksum(String name) {
|
||||
public static boolean isChecksum(String name) {
|
||||
// TODO can we drowp .cks
|
||||
return name.startsWith(CHECKSUMS_PREFIX) || name.endsWith(".cks"); // bwcomapt - .cks used to be a previous checksum file
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the file is auto-generated by the store and shouldn't be deleted during cleanup.
|
||||
* This includes write lock and checksum files
|
||||
*/
|
||||
public static boolean isAutogenerated(String name) {
|
||||
return IndexWriter.WRITE_LOCK_NAME.equals(name) || isChecksum(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a string representation of the given digest value.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user