Use transactions to handle comments when possible
If the database supports transactions (see gwtorm, not all do) try to perform some update operations as a single transaction on the change. This may allow the database to batch together any record updates, saving some time. Change-Id: I5af9efe3a541d83515109e3bf9a3497b3d8127de
This commit is contained in:
@@ -116,18 +116,25 @@ public class PublishComments implements Callable<VoidResult> {
|
||||
}
|
||||
drafts = drafts();
|
||||
|
||||
publishDrafts();
|
||||
db.changes().beginTransaction(changeId);
|
||||
try {
|
||||
publishDrafts();
|
||||
|
||||
final boolean isCurrent = patchSetId.equals(change.currentPatchSetId());
|
||||
if (isCurrent && change.getStatus().isOpen()) {
|
||||
publishApprovals(ctl);
|
||||
} else if (! approvals.isEmpty()) {
|
||||
throw new InvalidChangeOperationException("Change is closed");
|
||||
} else {
|
||||
publishMessageOnly();
|
||||
final boolean isCurrent = patchSetId.equals(change.currentPatchSetId());
|
||||
if (isCurrent && change.getStatus().isOpen()) {
|
||||
publishApprovals(ctl);
|
||||
} else if (!approvals.isEmpty()) {
|
||||
throw new InvalidChangeOperationException("Change is closed");
|
||||
} else {
|
||||
publishMessageOnly();
|
||||
}
|
||||
|
||||
touchChange();
|
||||
db.commit();
|
||||
} finally {
|
||||
db.rollback();
|
||||
}
|
||||
|
||||
touchChange();
|
||||
email();
|
||||
fireHook();
|
||||
return VoidResult.INSTANCE;
|
||||
|
Reference in New Issue
Block a user