Handle the ReindexIfStale event when a change is deleted

It is possible that the ReindexIfStale task is executed by the time
the change is deleted, because the ReindexIfStale task is done
asynchronously. The NoSuchChangeException is handled for the Reindexing
event so that the ReindexIfStale task is not executed if the changed
is deleted.

Change-Id: I2d5f5c5df768fff858936b772695e171b073f1e0
This commit is contained in:
Borui Tao
2018-02-02 15:09:47 -05:00
parent dfc7e6d313
commit 6fe1d746a0

View File

@@ -33,6 +33,7 @@ import com.google.gerrit.server.index.Index;
import com.google.gerrit.server.index.IndexExecutor;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.util.RequestContext;
import com.google.gerrit.server.util.ThreadLocalRequestContext;
@@ -447,11 +448,15 @@ public class ChangeIndexer {
@Override
public Boolean callImpl(Provider<ReviewDb> db) throws Exception {
if (!stalenessChecker.isStale(id)) {
return false;
try {
if (stalenessChecker.isStale(id)) {
index(newChangeData(db.get(), project, id));
return true;
}
} catch (NoSuchChangeException e) {
log.debug("Change {} was deleted, aborting reindexing the change.", id.get());
}
index(newChangeData(db.get(), project, id));
return true;
return false;
}
@Override