Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-5852: log errors that occur during cleanupOldIndexFiles

Shai Ererac1e3b3b9a73d
diff --git a/lucene/replicator/src/java/org/apache/lucene/replicator/IndexAndTaxonomyReplicationHandler.java b/lucene/replicator/src/java/org/apache/lucene/replicator/IndexAndTaxonomyReplicationHandler.java
index 83aba75aeb9..9c925f6ec41 100644
--- a/lucene/replicator/src/java/org/apache/lucene/replicator/IndexAndTaxonomyReplicationHandler.java
+++ b/lucene/replicator/src/java/org/apache/lucene/replicator/IndexAndTaxonomyReplicationHandler.java
@@ -166,8 +166,8 @@ public class IndexAndTaxonomyReplicationHandler implements ReplicationHandler {
// side-effects, e.g. if it hits sudden IO errors while opening the index
// (and can end up deleting the entire index). It is not our job to protect
// against those errors, app will probably hit them elsewhere.
- IndexReplicationHandler.cleanupOldIndexFiles(indexDir, indexSegmentsFile);
- IndexReplicationHandler.cleanupOldIndexFiles(taxoDir, taxoSegmentsFile);
+ IndexReplicationHandler.cleanupOldIndexFiles(indexDir, indexSegmentsFile, infoStream);
+ IndexReplicationHandler.cleanupOldIndexFiles(taxoDir, taxoSegmentsFile, infoStream);
// successfully updated the index, notify the callback that the index is
// ready.
diff --git a/lucene/replicator/src/java/org/apache/lucene/replicator/IndexReplicationHandler.java b/lucene/replicator/src/java/org/apache/lucene/replicator/IndexReplicationHandler.java
index 86c4914e20f..34bbf476e10 100644
--- a/lucene/replicator/src/java/org/apache/lucene/replicator/IndexReplicationHandler.java
+++ b/lucene/replicator/src/java/org/apache/lucene/replicator/IndexReplicationHandler.java
@@ -141,7 +141,7 @@ public class IndexReplicationHandler implements ReplicationHandler {
* directory. It suppresses any exceptions that occur, as this can be retried
* the next time.
*/
- public static void cleanupOldIndexFiles(Directory dir, String segmentsFile) {
+ public static void cleanupOldIndexFiles(Directory dir, String segmentsFile, InfoStream infoStream) {
try {
IndexCommit commit = getLastCommit(dir);
// commit == null means weird IO errors occurred, ignore them
@@ -164,9 +164,12 @@ public class IndexReplicationHandler implements ReplicationHandler {
}
}
} catch (Throwable t) {
- // ignore any errors that happens during this state and only log it. this
+ // ignore any errors that happen during this state and only log it. this
// cleanup will have a chance to succeed the next time we get a new
// revision.
+ if (infoStream.isEnabled(INFO_STREAM_COMPONENT)) {
+ infoStream.message(INFO_STREAM_COMPONENT, "cleanupOldIndexFiles(): failed on error " + t.getMessage());
+ }
}
}
@@ -280,7 +283,7 @@ public class IndexReplicationHandler implements ReplicationHandler {
// side-effects, e.g. if it hits sudden IO errors while opening the index
// (and can end up deleting the entire index). It is not our job to protect
// against those errors, app will probably hit them elsewhere.
- cleanupOldIndexFiles(indexDir, segmentsFile);
+ cleanupOldIndexFiles(indexDir, segmentsFile, infoStream);
// successfully updated the index, notify the callback that the index is
// ready.