Don't run autoReindexIfStale indefinitely
Before this, the ReindexIfStaleTask class used index, which in turn calls autoReindexIfStale. This leads to an infinite loop if isStale returns true several times in a row. To my knowledge, this didn't happen in production, but I triggered it locally while testing things. Change-Id: Id5b5cbf15be0d6c8fd7d42d1e686a5c34801b91d
This commit is contained in:
@@ -184,15 +184,12 @@ public class ChangeIndexer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously index a change.
|
||||
* Synchronously index a change, then check if the index is stale due to a race condition.
|
||||
*
|
||||
* @param cd change to index.
|
||||
*/
|
||||
public void index(ChangeData cd) throws IOException {
|
||||
for (Index<?, ChangeData> i : getWriteIndexes()) {
|
||||
i.replace(cd);
|
||||
}
|
||||
fireChangeIndexedEvent(cd.project().get(), cd.getId().get());
|
||||
indexImpl(cd);
|
||||
|
||||
// Always double-check whether the change might be stale immediately after
|
||||
// interactively indexing it. This fixes up the case where two writers write
|
||||
@@ -215,6 +212,13 @@ public class ChangeIndexer {
|
||||
autoReindexIfStale(cd);
|
||||
}
|
||||
|
||||
private void indexImpl(ChangeData cd) throws IOException {
|
||||
for (Index<?, ChangeData> i : getWriteIndexes()) {
|
||||
i.replace(cd);
|
||||
}
|
||||
fireChangeIndexedEvent(cd.project().get(), cd.getId().get());
|
||||
}
|
||||
|
||||
private void fireChangeIndexedEvent(String projectName, int id) {
|
||||
for (ChangeIndexedListener listener : indexedListeners) {
|
||||
try {
|
||||
@@ -434,7 +438,7 @@ public class ChangeIndexer {
|
||||
public Boolean callImpl(Provider<ReviewDb> db) throws Exception {
|
||||
try {
|
||||
if (stalenessChecker.isStale(id)) {
|
||||
index(newChangeData(db.get(), project, id));
|
||||
indexImpl(newChangeData(db.get(), project, id));
|
||||
return true;
|
||||
}
|
||||
} catch (NoSuchChangeException nsce) {
|
||||
|
Reference in New Issue
Block a user