title: Spring Batch Itemreader pass same Object twice to Itemprocessor
body: <p>I have Spring batch with partition. The gridSize is 10, so it will spawn 10 threads. Everything is default Bean singleton. TaskExeutor has max 15, core pool 10.</p>
  
  <pre><code>@Bean
  @StepScope
  public RepositoryItemReader&lt;CustomObject&gt; reader(${executorContext[from]} from, ${executorContext[to], ${executorContext[partitonId]) {
      LOG.info("Partition ID: {} will process row from: {}  to: {}", partitionId, from, to);
      //here has the right output, say 1 to 10, 10 to 20, include from, exclude to
      RepositoryItemReader reader = new RepositoryItemReader();
      reader.setRepository(objectRepo);
      reader.setMethod("findByProcessedFromAndTo");
      //from here I pass in from and to to do the partition
      //omit sorts, pageSize,  params
      reader.setSaveState(false);
      return reader;
  }
  </code></pre>
  
  <p>Here is the reader, this reader will  return 4 rows in DB. CustomObject 1 to 4.</p>
  
  <pre><code>@Bean
  public class processor implements ItemProcessor() {
     @override
     public Object process(customObject) {
         logger.info(customObject.getId());
         //logic
     }
  }
  
  @Bean
  Step processStep(){
      //chunk 1
      //item reader
      //item processor
      //item writer
      //build
  }
  
  Step partitionStep {
      //partion with gridSize 10,
      //processStep
      //taskExecutor
  }
  
  Partition  {
      int start = 1;
      int range = totalCount/gridSize + 1;
      for(i to gridSize){
          ExecutionContext context = New ExecutionContext();
         context.put("from",start);
         context.put("to", start*range);
         start += range;
         context.put("partitionId", i); 
         map.put(PARTITION_KEY, context);      
      }
      return map;
  }
  </code></pre>
  
  <p>The sample Query:</p>
  
  <pre><code>select * from Table where rownum &gt;=:from and rownum &lt; :to;
  </code></pre>
  
  <p>The Setup is very simple. Just a batch process with partition gridsize 10.</p>
  
  <p>When I run it, Item reader gets 4 records which is correct. But when reader pass the data to item processor, I got such log, I am making number up.</p>
  
  <pre><code>Thread 2 processing Object Id: 11 //row 10 to 20
  Thread 1 processing Object Id: 1 //row  1 to 10
  Thread 4 processing Object Id: 31 //row  30 to 40
  Thread 6 processing Object Id: 51 //row  50 to 60
  </code></pre>
  
  <p>Since I implementate the partition and do the partition in the query. Now all thread should process the partitioned set and should not process the duplicate record,  but still I got the same issue, some thread will process the duplicate record.</p>
  
  <pre><code>Thread 9 processing Object ID:2
  Thread 3 processing Object ID:4
  and so on
  </code></pre>
  
  <p>And when the whole job finishes, there will be unprocessed records in db.</p>
  
  <p>Did I missing something, need some help. </p>