Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] DuplicateKeyException encountered while retrieving the job execution history #277

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;

import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;

import lombok.NonNull;
Expand Down Expand Up @@ -596,7 +597,12 @@ private void syncHistoryJobInfoToDb(
JobInstanceHistory byInstanceId =
jobInstanceHistoryDao.getByInstanceId(jobInstance.getId());
if (byInstanceId == null) {
jobInstanceHistoryDao.insert(jobHistoryFromEngine);
try {
jobInstanceHistoryDao.insert(jobHistoryFromEngine);
} catch (DuplicateKeyException e) {
// Handle the race condition gracefully
jobInstanceHistoryDao.updateJobInstanceHistory(jobHistoryFromEngine);
}
} else {
jobInstanceHistoryDao.updateJobInstanceHistory(jobHistoryFromEngine);
}
Expand Down