Announcement Announcement Module
Collapse
No announcement yet.
Encountered an error saving batch meta data Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Encountered an error saving batch meta data

    I have a situation where the db throws error while inserting a record.
    The step execution end_time and status are not updated.
    The job execution is updated to to completed preventing it from restart.

    Here's the log

    Code:
    22:32:37,222 DEBUG main ExchRateDaoImpl:26 - [ExchRate-exchRateId=[ExchRateId-fromCurr=USD,toCurr=EUR-FIM,exchRateDt=Thu Oct 01 00:00:00 EDT 2009,srcVendI=X],spot=0.6879471657,thirty=null,sixty=null,ninety=null,oneEighty=null,threeSixty=null,updD=Wed Jan 27 22:32:04 EST 2010,updUsrI=fabatch]
    Hibernate: select exchrate_.from_curr, exchrate_.to_curr, exchrate_.exch_rate_dt, exchrate_.src_vend_i, exchrate_.spot as spot4_, exchrate_.thirty as thirty4_, exchrate_.sixty as sixty4_, exchrate_.ninety as ninety4_, exchrate_.one_eighty as one9_4_, exchrate_.three_sixty as three10_4_, exchrate_.upd_d as upd11_4_, exchrate_.upd_usr_i as upd12_4_ from gsampm.dbo.exch_rate exchrate_ where exchrate_.from_curr=? and exchrate_.to_curr=? and exchrate_.exch_rate_dt=? and exchrate_.src_vend_i=?
    22:32:37,347 DEBUG main ChunkOrientedTasklet:87 - Inputs not busy, ended: true
    22:32:37,363 DEBUG main TaskletStep:381 - Applying contribution: [StepContribution: read=4, written=1, filtered=3, readSkips=0, writeSkips=0, processSkips=0, exitStatus=EXECUTING]
    22:32:37,363 DEBUG main TaskletStep:393 - Saving step execution before commit: StepExecution: id=145, name=exchRateJob.exchRateLoad, status=STARTED, exitStatus=EXECUTING, readCount=4, filterCount=3, writeCount=1 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=1, rollbackCount=0, exitDescription=
    Hibernate: insert into gsampm.dbo.exch_rate (spot, thirty, sixty, ninety, one_eighty, three_sixty, upd_d, upd_usr_i, from_curr, to_curr, exch_rate_dt, src_vend_i) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    22:32:37,425  WARN main JDBCExceptionReporter:100 - SQL Error: 2601, SQLState: 23000
    22:32:37,425 ERROR main JDBCExceptionReporter:101 - Attempt to insert duplicate key row in object 'exch_rate' with unique index 'exch_rate_1'
    
    22:32:37,425  WARN main JDBCExceptionReporter:100 - SQL Error: 3621, SQLState: 01ZZZ
    22:32:37,425 ERROR main JDBCExceptionReporter:101 - Command has been aborted.
    
    22:32:37,441 ERROR main AbstractFlushingEventListener:324 - Could not synchronize database state with session
    org.hibernate.exception.ConstraintViolationException: could not insert: [my.domain.ExchRate]
    	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2285)
    	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678)
    	at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
    	at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
    	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
    	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
    	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
    	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
    	at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
    	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:147)
    	at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:261)
    	at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76)
    	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:368)
    	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214)
    	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
    	at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:247)
    	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:196)
    	at org.springframework.batch.core.configuration.xml.SimpleFlowFactoryBean$DelegateStep.execute(SimpleFlowFactoryBean.java:175)
    	at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:375)
    	at org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43)
    	at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:135)
    	at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
    	at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
    	at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
    	at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:103)
    	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:266)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:118)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:112)
    	at test.TestExchRate.main(TestExchRate.java:24)
    Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Attempt to insert duplicate key row in object 'exch_rate' with unique index 'exch_rate_1'
    
    	at com.sybase.jdbc3.tds.Tds.processEed(Tds.java:2942)
    	at com.sybase.jdbc3.tds.Tds.nextResult(Tds.java:2246)
    	at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
    	at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:220)
    	at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:203)
    	at com.sybase.jdbc3.jdbc.SybStatement.updateLoop(SybStatement.java:1804)
    	at com.sybase.jdbc3.jdbc.SybStatement.executeUpdate(SybStatement.java:1787)
    	at com.sybase.jdbc3.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatement.java:116)
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
    	at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
    	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2265)
    	... 34 more
    22:32:37,488 DEBUG main RepeatTemplate:292 - Handling exception: org.springframework.dao.DataIntegrityViolationException, caused by: org.springframework.dao.DataIntegrityViolationException: could not insert: [my.domain.ExchRate]; SQL [insert into gsampm.dbo.exch_rate (spot, thirty, sixty, ninety, one_eighty, three_sixty, upd_d, upd_usr_i, from_curr, to_curr, exch_rate_dt, src_vend_i) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [my.domain.ExchRate]
    22:32:37,488 DEBUG main RepeatTemplate:251 - Handling fatal exception explicitly (rethrowing first of 1): org.springframework.dao.DataIntegrityViolationException: could not insert: [my.domain.ExchRate]; SQL [insert into gsampm.dbo.exch_rate (spot, thirty, sixty, ninety, one_eighty, three_sixty, upd_d, upd_usr_i, from_curr, to_curr, exch_rate_dt, src_vend_i) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [my.domain.ExchRate]
    22:32:37,488 ERROR main AbstractStep:213 - Encountered an error executing the step

  • #2
    Code:
    Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Attempt to insert duplicate key row in object 'exch_rate' with unique index 'exch_rate_1'
    
    	at com.sybase.jdbc3.tds.Tds.processEed(Tds.java:2942)
    	at com.sybase.jdbc3.tds.Tds.nextResult(Tds.java:2246)
    	at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
    	at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:220)
    	at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:203)
    	at com.sybase.jdbc3.jdbc.SybStatement.updateLoop(SybStatement.java:1804)
    	at com.sybase.jdbc3.jdbc.SybStatement.executeUpdate(SybStatement.java:1787)
    	at com.sybase.jdbc3.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatement.java:116)
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
    	at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
    	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2265)
    	... 34 more
    
    22:32:37,644  INFO main XmlBeanDefinitionReader:315 - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
    22:32:37,738  INFO main SQLErrorCodesFactory:125 - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
    22:32:37,785 ERROR main AbstractStep:251 - Encountered an error saving batch meta data.This job is now in an unknown state and should not be restarted.
    22:32:37,785 DEBUG main AbstractStep:265 - Step execution complete: StepExecution: id=145, name=exchRateJob.exchRateLoad, status=UNKNOWN, exitStatus=UNKNOWN, readCount=4, filterCount=3, writeCount=1 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=1, rollbackCount=0
    22:32:37,816 DEBUG main SimpleFlow:156 - Completed state=exchRateJob.exchRateLoad with status=UNKNOWN
    22:32:37,816 DEBUG main SimpleFlow:143 - Handling state=exchRateJob.end1
    22:32:37,816 DEBUG main SimpleFlow:156 - Completed state=exchRateJob.end1 with status=COMPLETED
    22:32:37,816 DEBUG main AbstractJob:267 - Job execution complete: JobExecution: id=142, startTime=Wed Jan 27 22:29:48 EST 2010, endTime=null, lastUpdated=Wed Jan 27 22:29:48 EST 2010, status=COMPLETED, exitStatus=exitCode=COMPLETED;exitDescription=, job=[JobInstance: id=142, JobParameters=[{param_key=60}], Job=[exchRateJob]]
    22:34:56,569  INFO main SimpleJobLauncher:119 - Job: [FlowJob: [name=exchRateJob]] completed with the following parameters: [{param_key=60}] and the following status: [COMPLETED]

    Comment


    • #3
      Looks like this is a bug.

      An error in the writer - step execution doesn't get updated but job is marked as complete with sybase 12.5 as database.

      I tried debugging but unfortunately was not able to pin point the problem.

      I have hit a road block - can someone please look into this?

      Code:
      21:56:40,918 ERROR main AbstractStep:213 - Encountered an error executing the step
      java.lang.RuntimeException: May day , going down
      	at my.test.Writer.write(Writer.java:15)
      	at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:156)
      	at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:137)
      	at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:252)
      	at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:178)
      	at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:74)
      	at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:347)
      	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
      	at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:261)
      	at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76)
      	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:368)
      	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214)
      	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
      	at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:247)
      	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:196)
      	at org.springframework.batch.core.configuration.xml.SimpleFlowFactoryBean$DelegateStep.execute(SimpleFlowFactoryBean.java:175)
      	at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:375)
      	at org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43)
      	at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:135)
      	at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
      	at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
      	at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
      	at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:103)
      	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:266)
      	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:118)
      	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
      	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:112)
      	at my.test.TestJob.main(TestJob.java:26)
      21:56:40,949 DEBUG main JdbcStepExecutionDao:203 - Truncating long message before update of StepExecution, original message is: java.lang.RuntimeException: May day , going down
      	at my.test.Writer.write(Writer.java:15)
      	at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:156)
      	at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:137)
      	at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:252)
      	at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:178)
      	at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:74)
      	at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:347)
      	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
      	at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:261)
      	at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76)
      	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:368)
      	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214)
      	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
      	at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:247)
      	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:196)
      	at org.springframework.batch.core.configuration.xml.SimpleFlowFactoryBean$DelegateStep.execute(SimpleFlowFactoryBean.java:175)
      	at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:375)
      	at org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43)
      	at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:135)
      	at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
      	at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
      	at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
      	at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:103)
      	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:266)
      	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:118)
      	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
      	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:112)
      	at my.test.TestJob.main(TestJob.java:26)
      
      21:56:40,996  INFO main XmlBeanDefinitionReader:315 - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
      21:56:41,121  INFO main SQLErrorCodesFactory:125 - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
      21:56:41,137 ERROR main AbstractStep:251 - Encountered an error saving batch meta data.This job is now in an unknown state and should not be restarted.
      21:56:41,137 DEBUG main AbstractStep:265 - Step execution complete: StepExecution: id=154, name=mytest.test, status=UNKNOWN, exitStatus=UNKNOWN, readCount=2, filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=0, rollbackCount=1
      21:56:41,152 DEBUG main SimpleFlow:156 - Completed state=mytest.test with status=UNKNOWN
      21:56:41,152 DEBUG main SimpleFlow:143 - Handling state=mytest.end1
      21:56:41,152 DEBUG main SimpleFlow:156 - Completed state=mytest.end1 with status=COMPLETED
      21:56:41,152 DEBUG main AbstractJob:267 - Job execution complete: JobExecution: id=151, startTime=Thu Jan 28 21:56:40 EST 2010, endTime=null, lastUpdated=Thu Jan 28 21:56:40 EST 2010, status=COMPLETED, exitStatus=exitCode=COMPLETED;exitDescription=, job=[JobInstance: id=150, JobParameters=[{param_key=3}], Job=[mytest]]
      21:56:41,168  INFO main SimpleJobLauncher:119 - Job: [FlowJob: [name=mytest]] completed with the following parameters: [{param_key=3}] and the following status: [COMPLETED]

      Comment


      • #4
        The problem is just that you haven't flushed the Hibernate session in your writer, so it gets flushed automatically when the transaction commits and then causes an exception in a place that the framework cannot easily recover from.

        What version of Batch are you using? Upgrading might also help because meta-data failures are treated more gracefully in 2.1.

        Finally, please note that this is a community forum and you might find that people ignore posts that look like demands or instructions (so don't ask if "someone can look into it").

        Comment


        • #5
          Dave,

          The log of previous post didn't include any database interaction its a simple writer that throw a exception, it uses DataSourceTransactionManager for repository.

          While creating the repository tables, the only change I made is change data type BIGINT to NUMERIC(19,0) as sybase 12.5 doesn't support BIGINT.

          I am using 2.1.0M3

          Would that cause a problem?

          Here's the writer code

          Code:
          public class Writer implements ItemWriter<String>{
          
          	
          	public void write(List<? extends String> items) throws Exception {
          		
          	 for(String item : items)	
          		System.out.println("in the writer- "+item);
          	 
          	 throw new Exception("May day , going down");
          	}
          
          }

          Comment


          • #6
            Maybe your writer didn't do anything with the database but something did:

            Code:
            <snip>
            org.hibernate.exception.ConstraintViolationException: could not insert: [my.domain.ExchRate]
            </snip>
            You still need to flush the session (the writer is the obvious place). 2.1.0.M3 is pretty old and doesn't have the changes I mentioned, so it still might be easier to fix / diagnose in the newer versions. Can you upgrade?

            Comment


            • #7
              Sorry for not being clear.

              The first two post used HbmTxMgr and database.

              To explore the error, I wrote a plain sample application that reads from a file using flatfilereader and the writer mentioned above.
              The batch repository is in sybase and this time it uses spring "DataSourceTransactionManager"

              The third post is log from the sample application.

              I'll try to upgrade and check.

              Comment


              • #8
                Looks like a problem with persisting the exit message, debugging the error coming out of the jdbcstepexecutedao class, sybase is complaining about field sizes...

                nested exception is com.sybase.jdbc3.jdbc.SybSQLException: Attempt to update or insert row failed because resultant row of size 2647 bytes is larger than the maximum size (1963 bytes) allowed for this table.

                Changing the size of the exit message length seems to resolve this.

                i.e.

                <b:bean id="jobRepository"
                class="org.springframework.batch.core.repository.s upport.JobRepositoryFactoryBean"
                p:dataSource-ref="pmdbDataSource" p:transactionManager-ref="transactionManager"
                p:exitMessageLength="500"
                />

                You need to set the exit message length somewhere below 1963 as sybase will use some space for all the othe types in table, to get the max length you'd need to calc the size of each field type within the table to see how much you've actually got to play with.

                Not sure on other versions of sybase, perhaps they can take values greater then 2500 (as in the sybase sql script bundled, which also equals the default exit message size configured in the job repository).

                Perhaps the sybase sql script should be changed to TEXT, or some funky way for the spring system to auto detect the column lengths and truncate as needed?

                Comment


                • #9
                  I still feel the persistence of batch metadata should be more cleaner.

                  Exception occurs in the writer, there's a failure in persisting step context - shouldn't the job fail ?

                  Comment


                  • #10
                    Originally posted by Nitty View Post
                    Exception occurs in the writer, there's a failure in persisting step context - shouldn't the job fail ?
                    It should. Can you raise a JIRA? Attach some test code if you have any.

                    Comment


                    • #11
                      http://jira.springframework.org/browse/BATCH-1503

                      Comment


                      • #12
                        Hi there,

                        I am using Spring Batch 2.1.0 and Spring Core 3.0.2. I get the following error: [Has this error been resolved] How to prevent this error? We are using Oracle 10g RAC


                        2010-04-22 19:16:58,592 506748 ERROR [task-scheduler-1] [REQ-20100422190836-1] AbstractStep - Encountered an error saving batch meta data.This job is now in an unknown state and should not be restarted.

                        Here is the debug log of the above error:

                        Code:
                        
                        2010-04-22 19:47:44,057 554469 DEBUG [task-scheduler-4] [REQ-20100422193851-1] TaskletStep - Rollback for RuntimeException: org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [UPDATE BAT.BATCH_STEP_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE STEP_EXECUTION_ID = ?]; SQL state [72000]; error code [12899]; ORA-12899: value too large for column "BAT"."BATCH_STEP_EXECUTION_CONTEXT"."SHORT_CONTEXT" (actual: 2502, maximum: 2500)
                        ; nested exception is java.sql.SQLException: ORA-12899: value too large for column "BAT"."BATCH_STEP_EXECUTION_CONTEXT"."SHORT_CONTEXT" (actual: 2502, maximum: 2500)
                        
                        2010-04-22 19:47:44,057 554469 DEBUG [task-scheduler-4] [REQ-20100422193851-1] TransactionTemplate - Initiating transaction rollback on application exception
                        org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [UPDATE BAT.BATCH_STEP_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE STEP_EXECUTION_ID = ?]; SQL state [72000]; error code [12899]; ORA-12899: value too large for column "BAT"."BATCH_STEP_EXECUTION_CONTEXT"."SHORT_CONTEXT" (actual: 2502, maximum: 2500)
                        ; nested exception is java.sql.SQLException: ORA-12899: value too large for column "BAT"."BATCH_STEP_EXECUTION_CONTEXT"."SHORT_CONTEXT" (actual: 2502, maximum: 2500)
                        
                        	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
                        	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
                        	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
                        	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:602)
                        	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:811)
                        	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:867)
                        	at org.springframework.batch.core.repository.dao.JdbcExecutionContextDao.persistSerializedContext(JdbcExecutionContextDao.java:193)
                        	at org.springframework.batch.core.repository.dao.JdbcExecutionContextDao.updateExecutionContext(JdbcExecutionContextDao.java:136)
                        	at org.springframework.batch.core.repository.support.SimpleJobRepository.updateExecutionContext(SimpleJobRepository.java:178)
                        	at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
                        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                        	at java.lang.reflect.Method.invoke(Unknown Source)
                        	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
                        	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
                        	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
                        	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
                        	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                        	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
                        	at $Proxy13.updateExecutionContext(Unknown Source)
                        	at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:391)
                        	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
                        	at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:262)
                        	at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76)
                        	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367)
                        	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214)
                        	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
                        	at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:247)
                        	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:196)
                        	at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:115)
                        	at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61)
                        	at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
                        	at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
                        	at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
                        	at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:99)
                        	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281)
                        	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
                        	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
                        	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114)
                        	at test.co.batch.stuff.serviceactivator.JobInvoker.launchBatchJob(JobInvoker.java:230)
                        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                        	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                        	at java.lang.reflect.Method.invoke(Unknown Source)
                        	at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:58)
                        	at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:103)
                        	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
                        	at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)
                        	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:93)
                        	at org.springframework.integration.handler.AbstractMessageProcessor.evaluateExpression(AbstractMessageProcessor.java:48)
                        	at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:164)
                        	at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:60)
                        	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:91)
                        	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:63)
                        	at org.springframework.integration.endpoint.HandlerInvocationChain.handleMessage(HandlerInvocationChain.java:58)
                        	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:103)
                        	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:90)
                        	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:43)
                        	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:176)
                        	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:149)
                        	at org.springframework.integration.channel.MessageChannelTemplate.doSend(MessageChannelTemplate.java:224)
                        	at org.springframework.integration.channel.MessageChannelTemplate.send(MessageChannelTemplate.java:181)
                        	at org.springframework.integration.endpoint.SourcePollingChannelAdapter.doPoll(SourcePollingChannelAdapter.java:78)
                        	at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.innerPoll(AbstractPollingEndpoint.java:236)
                        	at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.poll(AbstractPollingEndpoint.java:220)
                        	at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:213)
                        	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:51)
                        	at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
                        	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
                        	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
                        	at java.util.concurrent.FutureTask.run(Unknown Source)
                        	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
                        	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
                        	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
                        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
                        	at java.lang.Thread.run(Unknown Source)
                        Caused by: java.sql.SQLException: ORA-12899: value too large for column "BAT"."BATCH_STEP_EXECUTION_CONTEXT"."SHORT_CONTEXT" (actual: 2502, maximum: 2500)
                        Table BATCH_STEP_EXECUTION_CONTEXT details
                        STEP_EXECUTION_ID NUMBER (19,0)
                        STEP_SHORT_CONTEXT VARCHAR2 (4000 CHAR)
                        SERIALIZED_CONTEXT CLOB

                        Thanks.
                        Last edited by msns3ka; Apr 22nd, 2010, 04:08 AM.

                        Comment


                        • #13
                          Solved this issue!

                          Table BATCH_STEP_EXECUTION_CONTEXT details (not correct in my previous post above)

                          STEP_EXECUTION_ID NUMBER (19,0)
                          STEP_SHORT_CONTEXT VARCHAR2 (2500 CHAR)
                          SERIALIZED_CONTEXT CLOB

                          Increased the field 'STEP_SHORT_CONTEXT' size from 2500 to 3000 and it worked OK !

                          Comment


                          • #14
                            Look at the job-repository configuration carefully. There is an option there to set the max-varchar-length.

                            Comment


                            • #15
                              Dave,

                              I tried that (increasing max-varchar-length to 3000) and still the same error. Then I increased the size of field STEP_SHORT_CONTEXT to 3000 (in table BATCH_STEP_EXECUTION_CONTEXT) and then only it worked fine.

                              My Application's Step Context is very big as we are using around 20 file writers! :-)

                              But anyway in the first place when we receive this error 'AbstractStep - Encountered an error saving batch meta data.This job is now in an unknown state and should not be restarted.' the JOB status should be set to FAILED but the status is set to COMPLETED. [I thinks there is a Jira http://jira.springframework.org/browse/BATCH-1503 for this and hoping it is fixed for the next release.]



                              Cheers
                              Last edited by msns3ka; Apr 23rd, 2010, 05:10 PM.

                              Comment

                              Working...
                              X