Run change hooks and ref-updated events after indexing is done.

The change hooks and ref-updated events were run parallel to the
change (re)indexing. This meant that an event-stream sent events
to the clients before the change indexing was finished. If a client
queried for that change immediately after receiving the event it
happened that the response was not-found as the indexing wasn't yet
done.

Although we haven't had issues with a ref-updated event processors,
firing this event will also wait for the indexing task to finish
as we never know if a ref-updated event processor may trigger a
change query.

Change-Id: Iff17c5aeb9675f3991f938d31ef5048ef5b3b956
This commit is contained in:
Saša Živkov
2014-08-01 16:33:31 +02:00
committed by Hugo Arès
parent 70b4f8f703
commit 22e43cc823
10 changed files with 52 additions and 53 deletions

View File

@@ -840,6 +840,7 @@ public class MergeOp {
db.commit();
sendMergedEmail(c, submitter);
indexer.index(db, c);
if (submitter != null) {
try {
hooks.doChangeMergedHook(c,
@@ -852,7 +853,6 @@ public class MergeOp {
} finally {
db.rollback();
}
indexer.index(db, c);
}
private Change setMergedPatchSet(Change.Id changeId, final PatchSet.Id merged)
@@ -1065,6 +1065,14 @@ public class MergeOp {
}
}));
if (indexFuture != null) {
try {
indexFuture.checkedGet();
} catch (IOException e) {
log.error("Failed to index new change message", e);
}
}
if (submitter != null) {
try {
hooks.doMergeFailedHook(c,
@@ -1074,13 +1082,6 @@ public class MergeOp {
log.error("Cannot run hook for merge failed " + c.getId(), ex);
}
}
if (indexFuture != null) {
try {
indexFuture.checkedGet();
} catch (IOException e) {
log.error("Failed to index new change message", e);
}
}
}
private void abandonAllOpenChanges() {