Skip to content

Commit 6227525

Browse files
Optimize UsageJobDaoImpl.updateJobSuccess to use direct UPDATE instead of row-level lock (apache#13160)
Co-authored-by: Aaron Chung <aaron_chung@apple.com>
1 parent 95d0aed commit 6227525

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

engine/schema/src/main/java/com/cloud/usage/dao/UsageJobDaoImpl.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,15 @@ public long getLastJobSuccessDateMillis() {
6161
public void updateJobSuccess(Long jobId, long startMillis, long endMillis, long execTime, boolean success) {
6262
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
6363
try {
64-
txn.start();
65-
66-
UsageJobVO job = lockRow(jobId, Boolean.TRUE);
6764
UsageJobVO jobForUpdate = createForUpdate();
6865
jobForUpdate.setStartMillis(startMillis);
6966
jobForUpdate.setEndMillis(endMillis);
7067
jobForUpdate.setExecTime(execTime);
7168
jobForUpdate.setStartDate(new Date(startMillis));
7269
jobForUpdate.setEndDate(new Date(endMillis));
7370
jobForUpdate.setSuccess(success);
74-
update(job.getId(), jobForUpdate);
75-
76-
txn.commit();
71+
update(jobId, jobForUpdate);
7772
} catch (Exception ex) {
78-
txn.rollback();
7973
logger.error("error updating job success date", ex);
8074
throw new CloudRuntimeException(ex.getMessage());
8175
} finally {

0 commit comments

Comments
 (0)