- better handling of index corruption: do clearIndex at checkRebuild request anyway. Previously we did it in invokeLater and that fails if corruption was detected at shutdown, e.g. IDEA-103038

- avoid multiple logging of corrupted index
This commit is contained in:
Maxim.Mossienko
2013-03-27 16:24:53 +01:00
parent 8cbd84c1c4
commit 101e4e41f3
@@ -1247,7 +1247,6 @@ public class FileBasedIndexImpl extends FileBasedIndex {
@Override @Override
public <K> void scheduleRebuild(@NotNull final ID<K, ?> indexId, @NotNull final Throwable e) { public <K> void scheduleRebuild(@NotNull final ID<K, ?> indexId, @NotNull final Throwable e) {
LOG.info(e);
requestRebuild(indexId, new Throwable(e)); requestRebuild(indexId, new Throwable(e));
try { try {
checkRebuild(indexId, false); checkRebuild(indexId, false);
@@ -1264,19 +1263,20 @@ public class FileBasedIndexImpl extends FileBasedIndex {
if (status.compareAndSet(REQUIRES_REBUILD, REBUILD_IN_PROGRESS)) { if (status.compareAndSet(REQUIRES_REBUILD, REBUILD_IN_PROGRESS)) {
cleanupProcessedFlag(); cleanupProcessedFlag();
try {
clearIndex(indexId);
} catch (StorageException ex) {
requestRebuild(indexId, new Throwable(ex));
}
final Runnable rebuildRunnable = new Runnable() { final Runnable rebuildRunnable = new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
clearIndex(indexId);
if (!cleanupOnly) { if (!cleanupOnly) {
scheduleIndexRebuild(false); scheduleIndexRebuild(false);
} }
} }
catch (StorageException e) {
requestRebuild(indexId);
LOG.info(e);
}
finally { finally {
status.compareAndSet(REBUILD_IN_PROGRESS, OK); status.compareAndSet(REBUILD_IN_PROGRESS, OK);
} }
@@ -1581,8 +1581,8 @@ public class FileBasedIndexImpl extends FileBasedIndex {
@Override @Override
public void requestRebuild(ID<?, ?> indexId, Throwable throwable) { public void requestRebuild(ID<?, ?> indexId, Throwable throwable) {
cleanupProcessedFlag(); cleanupProcessedFlag();
LOG.info("Rebuild requested for index " + indexId, throwable); boolean requiresRebuildWasSet = ourRebuildStatus.get(indexId).compareAndSet(OK, REQUIRES_REBUILD);
ourRebuildStatus.get(indexId).compareAndSet(OK, REQUIRES_REBUILD); if (requiresRebuildWasSet) LOG.info("Rebuild requested for index " + indexId, throwable);
} }
private <K, V> UpdatableIndex<K, V, FileContent> getIndex(ID<K, V> indexId) { private <K, V> UpdatableIndex<K, V, FileContent> getIndex(ID<K, V> indexId) {