don't write checksum file for the segments file, we anyhow recover it and that way the index can be read by pure Lucene code

This commit is contained in:
kimchy 2010-11-09 14:27:28 +02:00
parent b5f1a1b49c
commit f9fb67616d
3 changed files with 14 additions and 20 deletions

View File

@ -531,7 +531,8 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo
} catch (Exception e) { } catch (Exception e) {
// no file // no file
} }
if (!fileName.contains("segment") && md != null && fileInfo.isSame(md)) { // we don't compute checksum for segments, so always recover them
if (!fileName.startsWith("segments") && md != null && fileInfo.isSame(md)) {
numberOfFiles++; numberOfFiles++;
totalSize += md.length(); totalSize += md.length();
numberOfReusedFiles++; numberOfReusedFiles++;

View File

@ -100,7 +100,8 @@ public class RecoverySource extends AbstractComponent {
StoreFileMetaData md = shard.store().metaData(name); StoreFileMetaData md = shard.store().metaData(name);
boolean useExisting = false; boolean useExisting = false;
if (request.existingFiles().containsKey(name)) { if (request.existingFiles().containsKey(name)) {
if (!name.contains("segment") && md.isSame(request.existingFiles().get(name))) { // we don't compute checksum for segments, so always recover them
if (!name.startsWith("segments") && md.isSame(request.existingFiles().get(name))) {
response.phase1ExistingFileNames.add(name); response.phase1ExistingFileNames.add(name);
response.phase1ExistingFileSizes.add(md.length()); response.phase1ExistingFileSizes.add(md.length());
existingTotalSize += md.length(); existingTotalSize += md.length();

View File

@ -233,10 +233,12 @@ public abstract class AbstractStore extends AbstractIndexShardComponent implemen
public IndexOutput createOutput(String name, boolean computeChecksum) throws IOException { public IndexOutput createOutput(String name, boolean computeChecksum) throws IOException {
IndexOutput out = delegate.createOutput(name); IndexOutput out = delegate.createOutput(name);
// delete the relevant cks file for an existing file, if exists // delete the relevant cks file for an existing file, if exists
try { if (filesMetadata.containsKey(name)) {
delegate.deleteFile(name + ".cks"); try {
} catch (Exception e) { delegate.deleteFile(name + ".cks");
// ignore } catch (Exception e) {
// ignore
}
} }
synchronized (mutex) { synchronized (mutex) {
StoreFileMetaData metaData = new StoreFileMetaData(name, -1, -1, null); StoreFileMetaData metaData = new StoreFileMetaData(name, -1, -1, null);
@ -285,25 +287,11 @@ public abstract class AbstractStore extends AbstractIndexShardComponent implemen
@Override public void sync(String name) throws IOException { @Override public void sync(String name) throws IOException {
if (sync) { if (sync) {
delegate.sync(name); delegate.sync(name);
try {
if (delegate.fileExists(name + ".cks")) {
delegate.sync(name + ".cks");
}
} catch (Exception e) {
//ignore
}
} }
} }
@Override public void forceSync(String name) throws IOException { @Override public void forceSync(String name) throws IOException {
delegate.sync(name); delegate.sync(name);
try {
if (delegate.fileExists(name + ".cks")) {
delegate.sync(name + ".cks");
}
} catch (Exception e) {
//ignore
}
} }
} }
@ -322,6 +310,10 @@ public abstract class AbstractStore extends AbstractIndexShardComponent implemen
if ("segments.gen".equals(name)) { if ("segments.gen".equals(name)) {
// no need to create checksum for segments.gen since its not snapshot to recovery // no need to create checksum for segments.gen since its not snapshot to recovery
this.digest = null; this.digest = null;
} else if (name.startsWith("segments")) {
// don't compute checksum for segments files, so pure Lucene can open this directory
// and since we, in any case, always recover the segments files
this.digest = null;
} else { } else {
this.digest = Digest.getMd5Digest(); this.digest = Digest.getMd5Digest();
} }