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

Job restart after stop fails [BATCH-2315] #1287

Open
spring-projects-issues opened this issue Oct 28, 2014 · 5 comments
Open

Job restart after stop fails [BATCH-2315] #1287

spring-projects-issues opened this issue Oct 28, 2014 · 5 comments
Labels
has: minimal-example Bug reports that provide a minimal complete reproducible example in: core type: bug

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Oct 28, 2014

Chris Haas opened BATCH-2315 and commented

In our jobs we use the following construct to conditionally stop a job based on a property passed into the job:

<decision id="decisionId" decider="decider">
    <stop on="NEEDS_FINALIZATION" restart="placeAccounts"/>
    <next on="*" to="placeAccounts"/>
</decision>

In Spring Batch 2.1, "placeAccounts" is executed when the job is restarted. In Spring Batch 3, the decision is re-executed, which of course means the job immediately stops again.

In 3.0.1, the job's flow has stateTransitions for the decision look like

StateTransition: [state=placementImport.placementFinalizationDecision, pattern=*, next=placementImport.placeAccounts],
StateTransition: [state=placementImport.placementFinalizationDecision, pattern=NEEDS_FINALIZATION, next=placementImport.stop60],
StateTransition: [state=placementImport.stop60, pattern=*, next=null],

but in 2.1, they look like:

StateTransition: [state=placementImport.placementFinalizationDecision, pattern=*, next=placementImport.placeAccounts],
StateTransition: [state=placementImport.placementFinalizationDecision, pattern=NEEDS_FINALIZATION, next=placementImport.stop60],
StateTransition: [state=placementImport.stop60, pattern=*, next=placementImport.placeAccounts],

Notice that the next element on stop60 is blank, which is probably the cause of the problem.


Affects: 3.0.1

2 votes, 3 watchers

@spring-projects-issues
Copy link
Collaborator Author

Chris Haas commented

Attach an updated DecisionStepTests that illustrates the problem.

@spring-projects-issues
Copy link
Collaborator Author

Chris Haas commented

Note that, in all of the existing test cases, the step/decider keeps track of how many times it was called and, on a even number, returns a string to match the <next> tag, which means the restart attribute on the <stop> is never executed.

@spring-projects-issues
Copy link
Collaborator Author

Chris Haas commented

I've discovered the source of the problem. I had switched to the 3.0 schema, which adds the attribute exit-code to the <stop> tag, with a default value of "STOPPED". This value causes the restart attribute to be ignored. If I add exit-code="", the code runs as expected.

So,the bug fix is to update the documentation for the stop tag to indicate that it uses the exit-code attribute.

@spring-projects-issues
Copy link
Collaborator Author

Chris Haas commented

It would be nice to fix this, so that, during a <stop> you are allowed to change the ExitStatus - currently you cannot.

As a suggestion to see how bad the problem is, try upgrading one of the XML-based unit tests that uses <stop> to change the xsd reference from 2.2 to 3.0 - it will fail on restart.

@fmbenhassine
Copy link
Contributor

Minimal complete example to reproduce the issue here: https://github.com/benas/spring-batch-lab/tree/main/issues/gh1287

@fmbenhassine fmbenhassine added has: minimal-example Bug reports that provide a minimal complete reproducible example for: backport-to-4.2.x Issues that will be back-ported to the 4.2.x line and removed status: waiting-for-triage Issues that we did not analyse yet labels Aug 24, 2021
@fmbenhassine fmbenhassine added this to the 4.3.4 milestone Aug 24, 2021
@fmbenhassine fmbenhassine removed this from the 4.3.4 milestone Nov 3, 2021
@fmbenhassine fmbenhassine removed the for: backport-to-4.2.x Issues that will be back-ported to the 4.2.x line label Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has: minimal-example Bug reports that provide a minimal complete reproducible example in: core type: bug
Projects
None yet
Development

No branches or pull requests

2 participants