Log any failures updating the change index

If the index fails and nobody is waiting on the future the admin
doesn't know the index operation failed.  Always log the failure.

Change-Id: I3dfa859cf383bf0fa628ccc8b67d7a372ff95a1c
This commit is contained in:
Shawn Pearce
2013-06-25 12:24:00 -06:00
parent a2b71c85b1
commit 24f3a986d1
2 changed files with 16 additions and 8 deletions

View File

@@ -56,8 +56,6 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@@ -70,8 +68,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
public class Reindex extends SiteProgram {
private static final Logger log = LoggerFactory.getLogger(Reindex.class);
@Option(name = "--threads", usage = "Number of threads to use for indexing")
private int threads = Runtime.getRuntime().availableProcessors();
@@ -226,7 +222,6 @@ public class Reindex extends SiteProgram {
}
private void fail(Change change, Throwable t) {
log.error("Failed to index change " + change.getId(), t);
ok.set(false);
failed.update(1);
}

View File

@@ -21,6 +21,9 @@ import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.util.RequestScopePropagator;
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.concurrent.Callable;
@@ -31,6 +34,9 @@ import java.util.concurrent.Callable;
* compute some of the fields and/or update the index.
*/
public class ChangeIndexerImpl implements ChangeIndexer {
private static final Logger log =
LoggerFactory.getLogger(ChangeIndexerImpl.class);
private final ListeningScheduledExecutorService executor;
private final ChangeIndex index;
@@ -64,9 +70,16 @@ public class ChangeIndexerImpl implements ChangeIndexer {
}
@Override
public Void call() throws IOException {
index.replace(new ChangeData(change));
return null;
public Void call() throws Exception {
try {
index.replace(new ChangeData(change));
return null;
} catch (Exception e) {
log.error(String.format(
"Failed to index change %d in %s",
change.getChangeId(), change.getProject().get()), e);
throw e;
}
}
@Override