Do not abort indexing if < 50% projects failed
Run the project reindexing even if some of the projects could not be loaded. It is more important to keep the reindexing operation and leave to the Gerrit admin the troubleshooting of the failing projects. Log as error the project name that failed to be collected for indexing. Change-Id: I282ddae9a3211470d3fc8d9d26045bf7a8d3ac5c
This commit is contained in:
parent
12c2f1fb0a
commit
5c3e9e4b40
|
@ -111,20 +111,24 @@ public class AllChangesIndexer extends SiteIndexer<Change.Id, ChangeData, Change
|
|||
SortedSet<ProjectHolder> projects = new TreeSet<>();
|
||||
int changeCount = 0;
|
||||
Stopwatch sw = Stopwatch.createStarted();
|
||||
int projectsFailed = 0;
|
||||
for (Project.NameKey name : projectCache.all()) {
|
||||
try (Repository repo = repoManager.openRepository(name)) {
|
||||
long size = estimateSize(repo);
|
||||
changeCount += size;
|
||||
projects.add(new ProjectHolder(name, size));
|
||||
} catch (IOException e) {
|
||||
log.error("Error collecting projects", e);
|
||||
return new Result(sw, false, 0, 0);
|
||||
log.error("Error collecting project {}", name, e);
|
||||
projectsFailed++;
|
||||
if (projectsFailed > projects.size() / 2) {
|
||||
log.error("Over 50% of the projects could not be collected: aborted");
|
||||
return new Result(sw, false, 0, 0);
|
||||
}
|
||||
}
|
||||
pm.update(1);
|
||||
}
|
||||
pm.endTask();
|
||||
setTotalWork(changeCount);
|
||||
|
||||
return indexAll(index, projects);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue