Announcement Announcement Module
Collapse
No announcement yet.
Problem when AllowStartIfComplete of Step = true Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem when AllowStartIfComplete of Step = true

    Hi,

    M5 version.

    I have a SimpleJob with one SimpleStep that has the property allowStartIfComplete=true.
    The Step has one ItemReader and one CompositeItemWriter composed by 4 writers of file and one jdbc Writer. The output files can be deleted if exist.
    The fist time I run my job, the reader is read, the output files are written and the database is updated.
    The second time I run my job, the reader is read but the output files aren't written and the database isn't update. There isn't any exception but I have seen that le RepeatSynchronizationManager.getContext returns null while the first time it returns a context.

    I thougth when the allowStartIfComplete = true for a step, this step had to be executed like the first time (like it was in M3 version).

    Could you tell me if I am wrong or not?
    If not, could you resolve the problem in the next version?

    Precision : if allowStartIfComplete=false, the step isn't executed like in M3 version.

    Thanks.

  • #2
    I think the issue is that the step is actually restarted rather than re-run. As it is already complete, it jumps to the end state and does nothing. Will need to investigate that more closely.

    Comment


    • #3
      http://jira.springframework.org/browse/BATCH-454

      Comment


      • #4
        Hi,

        I have migrated in rc1 version.

        When the step has property allowStartIfComplete=true, the second time I run my job, I have the following error:
        2008-03-18 15:31:28,890 ERROR - Job Terminated in error:
        org.springframework.batch.core.repository.JobInsta nceAlreadyCompleteException: A job instance already exists is complete for parameters={batch.outputFile=200803181530.clients. txt}{}{}{}. If you want to run this job again, change the parameters.
        at org.springframework.batch.core.repository.support. SimpleJobRepository.createJobExecution(SimpleJobRe pository.java:171)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:618)
        at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:310)
        at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:182)
        at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :149)
        at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:106)
        at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
        at org.springframework.aop.interceptor.ExposeInvocati onInterceptor.invoke(ExposeInvocationInterceptor.j ava:90)
        at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
        at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy0.createJobExecution(Unknown Source)
        at org.springframework.batch.core.launch.support.Simp leJobLauncher.run(SimpleJobLauncher.java:83)
        at com.natixis.sphinx.batch.BatchMain.start(BatchMain .java:156)
        at com.natixis.sphinx.batch.BatchMain.main(BatchMain. java:206)
        I thougth that I was able to run my job with the same parameters several time when job is restartable and the steps are able to be started if complete?!

        Comment


        • #5
          I thougth that I was able to run my job with the same parameters several time when job is restartable and the steps are able to be started if complete?!
          Not really, the same job + parameters = the same JobInstance. And the lifecycle of JobInstance ends with first successful execution.

          Comment


          • #6
            As I didn't see the difference between true and false for allowStartIfComplete, I have tried with false.

            I have exactly the same error?!

            And how can I do to execute several time the same job with the same parameters?
            If I haven't any parameter, I have always a new job instance (if allowStartIfComplete=true or false). Is it the solution to run a job several times?

            Comment


            • #7
              If I haven't any parameter, I have always a new job instance (if allowStartIfComplete=true or false). Is it the solution to run a job several times?
              but in this case, if I have an error, I can't restart at the last commit point.

              Comment


              • #8
                You can't execute several times the same job with same parameters (same JobInstance). You need to add some identifying parameter to distinguish the runs e.g. timestamp.

                Running the same JobInstance more than once means restarting it - which makes sense only when last execution failed.

                If I haven't any parameter, I have always a new job instance
                What do you mean by that? Empty parameters are not special in any way, JobInstance = Job + JobParameters, no exceptions (at least in the current version).

                Comment


                • #9
                  Then What is the usefulness of the property AllowStartIfComplete (no difference between true and false value)?

                  by
                  If I haven't any parameter, I have always a new job instance
                  I mean that if I run my batch with
                  java org.springframework.batch.core.launch.support.Comm andLineJobRunner jobPath jobName
                  then JobInstance has a jobName but the jobKey is null and a new jobInstance is created when I restart my batch job.

                  Comment


                  • #10
                    Then What is the usefulness of the property AllowStartIfComplete (no difference between true and false value)?
                    The property value is relevant only in restart scenario - by default job skips completed steps when restarting.

                    About the empty parameters - do you say you get identical job instances in the database that differ only in ID? That would be a bug.

                    Comment


                    • #11
                      Thank you, I understand now my mistake.

                      do you say you get identical job instances in the database that differ only in ID
                      Yes , because the column job_key isn't NOT NULL.

                      Comment

                      Working...
                      X