Skip to content

Eliminate unnecessary query for current version #4797

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -74,6 +74,7 @@
* @author Dimitrios Liapis
* @author Philippe Marschall
* @author Jinwoo Bae
* @author Yanming Zhou
*/
public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements JobExecutionDao, InitializingBean {

Expand Down Expand Up @@ -319,11 +320,8 @@ public void updateJobExecution(JobExecution jobExecution) {

// Avoid concurrent modifications...
if (count == 0) {
int currentVersion = getJdbcTemplate().queryForObject(getQuery(CURRENT_VERSION_JOB_EXECUTION),
Integer.class, new Object[] { jobExecution.getId() });
throw new OptimisticLockingFailureException(
"Attempt to update job execution id=" + jobExecution.getId() + " with wrong version ("
+ jobExecution.getVersion() + "), where current version is " + currentVersion);
throw new OptimisticLockingFailureException("Attempt to update job execution id=" + jobExecution.getId()
+ " with wrong version (" + jobExecution.getVersion() + ")");
}

jobExecution.incrementVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
* @author Mahmoud Ben Hassine
* @author Baris Cubukcuoglu
* @author Minsoo Kim
* @author Yanming Zhou
* @see StepExecutionDao
*/
public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implements StepExecutionDao, InitializingBean {
Expand Down Expand Up @@ -100,11 +101,6 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
WHERE JE.JOB_INSTANCE_ID = ? AND SE.STEP_NAME = ?
""";

private static final String CURRENT_VERSION_STEP_EXECUTION = """
SELECT VERSION FROM %PREFIX%STEP_EXECUTION
WHERE STEP_EXECUTION_ID=?
""";

private static final String COUNT_STEP_EXECUTIONS = """
SELECT COUNT(*)
FROM %PREFIX%JOB_EXECUTION JE
Expand Down Expand Up @@ -287,11 +283,8 @@ public void updateStepExecution(StepExecution stepExecution) {

// Avoid concurrent modifications...
if (count == 0) {
int currentVersion = getJdbcTemplate().queryForObject(getQuery(CURRENT_VERSION_STEP_EXECUTION),
Integer.class, stepExecution.getId());
throw new OptimisticLockingFailureException(
"Attempt to update step execution id=" + stepExecution.getId() + " with wrong version ("
+ stepExecution.getVersion() + "), where current version is " + currentVersion);
throw new OptimisticLockingFailureException("Attempt to update step execution id="
+ stepExecution.getId() + " with wrong version (" + stepExecution.getVersion() + ")");
}

stepExecution.incrementVersion();
Expand Down
Loading