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

@@ -245,24 +245,23 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
ImmutableList.of(psa)));
}
accountLoaderFactory.create(true).fill(result.reviewers);
postAdd(rsrc.getChange(), added);
emailReviewers(rsrc.getChange(), added);
indexFuture.checkedGet();
if (!added.isEmpty()) {
PatchSet patchSet = dbProvider.get().patchSets().get(rsrc.getChange().currentPatchSetId());
for (PatchSetApproval psa : added) {
Account account = accountCache.get(psa.getAccountId()).getAccount();
hooks.doReviewerAddedHook(rsrc.getChange(), account, patchSet, dbProvider.get());
}
}
}
private void postAdd(Change change, List<PatchSetApproval> added)
private void emailReviewers(Change change, List<PatchSetApproval> added)
throws OrmException, EmailException {
if (added.isEmpty()) {
return;
}
// Execute hook for added reviewers
//
PatchSet patchSet = dbProvider.get().patchSets().get(change.currentPatchSetId());
for (PatchSetApproval psa : added) {
Account account = accountCache.get(psa.getAccountId()).getAccount();
hooks.doReviewerAddedHook(change, account, patchSet, dbProvider.get());
}
// Email the reviewers
//
// The user knows they added themselves, don't bother emailing them.