Catch exceptions on individual changes in reindex
Previously exceptions were only caught at the commit indexing level. This meant that any exceptions indexing a change on the commit will cause any potentially remaining changes for that commit to be skipped. Change-Id: I01f94ec8dea2cad352cc4766eb932d380f7bb065
This commit is contained in:
@@ -89,6 +89,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -377,6 +378,7 @@ public class Reindex extends SiteProgram {
|
|||||||
|
|
||||||
private void getPathsAndIndex(RevCommit bCommit) throws Exception {
|
private void getPathsAndIndex(RevCommit bCommit) throws Exception {
|
||||||
RevTree bTree = bCommit.getTree();
|
RevTree bTree = bCommit.getTree();
|
||||||
|
List<ChangeData> cds = byId.get(bCommit);
|
||||||
try {
|
try {
|
||||||
RevTree aTree = aFor(bCommit, walk);
|
RevTree aTree = aFor(bCommit, walk);
|
||||||
if (aTree == null) {
|
if (aTree == null) {
|
||||||
@@ -385,15 +387,20 @@ public class Reindex extends SiteProgram {
|
|||||||
DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
|
DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
|
||||||
try {
|
try {
|
||||||
df.setRepository(repo);
|
df.setRepository(repo);
|
||||||
List<ChangeData> cds = byId.get(bCommit);
|
|
||||||
if (!cds.isEmpty()) {
|
if (!cds.isEmpty()) {
|
||||||
List<String> paths = getPaths(df.scan(aTree, bTree));
|
List<String> paths = getPaths(df.scan(aTree, bTree));
|
||||||
for (ChangeData cd : cds) {
|
Iterator<ChangeData> cdit = cds.iterator();
|
||||||
cd.setCurrentFilePaths(paths);
|
for (ChangeData cd ; cdit.hasNext(); cdit.remove()) {
|
||||||
indexer.indexTask(cd).call();
|
cd = cdit.next();
|
||||||
done.update(1);
|
try {
|
||||||
if (verbose) {
|
cd.setCurrentFilePaths(paths);
|
||||||
System.out.println("Reindexed change " + cd.getId());
|
indexer.indexTask(cd).call();
|
||||||
|
done.update(1);
|
||||||
|
if (verbose) {
|
||||||
|
System.out.println("Reindexed change " + cd.getId());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail("Failed to index change " + cd.getId(), true, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -401,7 +408,10 @@ public class Reindex extends SiteProgram {
|
|||||||
df.release();
|
df.release();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail("Failed to index commit " + bCommit.name(), e);
|
fail("Failed to index commit " + bCommit.name(), false, e);
|
||||||
|
for (ChangeData cd : cds) {
|
||||||
|
fail("Failed to index change " + cd.getId(), true, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,8 +454,16 @@ public class Reindex extends SiteProgram {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fail(String error, Exception e) {
|
private void fail(String error, boolean failed, Exception e) {
|
||||||
log.warn(error, e);
|
if (failed) {
|
||||||
|
this.failed.update(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e != null) {
|
||||||
|
log.warn(error, e);
|
||||||
|
} else {
|
||||||
|
log.warn(error);
|
||||||
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
System.out.println(error);
|
System.out.println(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user