Apache Lucene open-source search software
SOLR-6637: Better error handling when retrieving checksums (Fixes Policeman Jenkins Failure #2134)
Varun Thackerf7d633a56e99
diff --git a/solr/core/src/java/org/apache/solr/handler/RestoreCore.java b/solr/core/src/java/org/apache/solr/handler/RestoreCore.javaindex 0d86ca57f89..25ff24ee5d1 100644--- a/solr/core/src/java/org/apache/solr/handler/RestoreCore.java+++ b/solr/core/src/java/org/apache/solr/handler/RestoreCore.java@@ -17,6 +17,7 @@ package org.apache.solr.handler;* limitations under the License.*/+import java.io.IOException;import java.nio.file.Path;import java.nio.file.Paths;import java.util.concurrent.Callable;@@ -72,9 +73,14 @@ public class RestoreCore implements Callable<Boolean> {//Move all files from backupDir to restoreIndexDirfor (String filename : backupDir.listAll()) {checkInterrupted();- log.info("Copying over file to restore directory " + filename);+ log.info("Copying file {} to restore directory ", filename);try (IndexInput indexInput = backupDir.openInput(filename, IOContext.READONCE)) {- long checksum = CodecUtil.retrieveChecksum(indexInput);+ Long checksum = null;+ try {+ checksum = CodecUtil.retrieveChecksum(indexInput);+ } catch (Exception e) {+ log.warn("Could not read checksum from index file: " + filename, e);+ }long length = indexInput.length();IndexFetcher.CompareResult compareResult = IndexFetcher.compareFile(indexDir, filename, length, checksum);if (!compareResult.equal || (!compareResult.checkSummed && (filename.endsWith(".si")diff --git a/solr/core/src/java/org/apache/solr/handler/SnapShooter.java b/solr/core/src/java/org/apache/solr/handler/SnapShooter.javaindex e6cb1ac1703..ffdafa5b310 100644--- a/solr/core/src/java/org/apache/solr/handler/SnapShooter.java+++ b/solr/core/src/java/org/apache/solr/handler/SnapShooter.java@@ -127,7 +127,7 @@ public class SnapShooter {}void createSnapshot(final IndexCommit indexCommit, ReplicationHandler replicationHandler) {- LOG.info("Creating backup snapshot " + (snapshotName == null ? "<not named>" : snapshotName));+ LOG.info("Creating backup snapshot " + (snapshotName == null ? "<not named>" : snapshotName) + " at " + snapDir);NamedList<Object> details = new NamedList<>();details.add("startTime", new Date().toString());try {@@ -144,7 +144,8 @@ public class SnapShooter {details.add("status", "success");details.add("snapshotCompletedAt", new Date().toString());details.add("snapshotName", snapshotName);- LOG.info("Done creating backup snapshot: " + (snapshotName == null ? "<not named>" : snapshotName));+ LOG.info("Done creating backup snapshot: " + (snapshotName == null ? "<not named>" : snapshotName) ++ " at " + snapDir);} catch (Exception e) {IndexFetcher.delTree(snapShotDir);LOG.error("Exception while creating snapshot", e);diff --git a/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java b/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.javaindex bdedc7c6331..e5d7adaa236 100644--- a/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java+++ b/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java@@ -26,6 +26,7 @@ import java.net.URLEncoder;import java.nio.file.Files;import java.nio.file.Path;import java.nio.file.Paths;+import java.util.regex.Matcher;import java.util.regex.Pattern;import org.apache.commons.io.IOUtils;@@ -226,8 +227,9 @@ public class TestRestoreCore extends SolrJettyTestBase {URL url = new URL(masterUrl);stream = url.openStream();String response = IOUtils.toString(stream, "UTF-8");- if(pException.matcher(response).find()) {- fail("Failed to complete restore action");+ Matcher matcher = pException.matcher(response);+ if(matcher.find()) {+ fail("Failed to complete restore action with exception " + matcher.group(1));}if(response.contains("<str name=\"status\">success</str>")) {return true;