title: Spring Boot (v2.3.1): Spring Batch Partition w/JdbcPagingItemReader using SimplePartitioner Helper Class
body: <p>I would like to gain some clarity on exactly how a Partitioner is supposed to work. I implemented the <code>SimplePartitioner</code> (helper class provided by Spring) into a <code>JdbcPagingItemReader</code>, it working for the most part but the issue is that I see duplicate data/records come through the <code>ItemWriter</code>. First I thought there was an issue with my query returning dupes, that is not the case. Right off the bat, the first couple of chunks that hit the writer are the same records. Reading through <a href="https://docs.spring.io/spring-batch/docs/current/reference/html/scalability.html#partitioning" rel="nofollow noreferrer">the docs</a> does not clarify enough about how the <code>Partitioner</code> is supposed to work. Are the dupes on multiple partitions supposed to happen? Perhaps a miss configuration on setting up the steps for partitioning? A simple example or a break down of how Partitioners actually work would be most helpful. Example of my setup below:</p>
  <pre><code>@Bean
  public Job job(@Qualifier(&quot;step-one&quot;) @Autowired Step stepOne) {
      return jobBuilderFactory.get(&quot;my-first-spring-batch&quot;)
          .start(stepOne)
      .build();
  }
  </code></pre>
  <pre><code>@Bean(name = &quot;PagingItemReader&quot;)
  @StepScope
  public JdbcPagingItemReader&lt;Product&gt; pagingItemReader(@Autowired PagingQueryProvider queryProvider) {
      return new JdbcPagingItemReaderBuilder&lt;Product&gt;().name(&quot;paging-reader&quot;)
          .dataSource(dataSource)
              .queryProvider(queryProvider)
                  .rowMapper(new TheMapper())
          .pageSize(100)
              .maxItemCount(1000)
                  .saveState(false)
      .build();
  }
  </code></pre>
  <pre><code>@Bean(name = &quot;step-one&quot;)
  public Step stepOne(@Qualifier(&quot;step-two&quot;) @Autowired Step stepTwo, @Autowired TaskExecutor taskExecutor, @Autowired SimplePartitioner partitioner) {
      return stepBuilderFactory.get(&quot;step-one-partition&quot;)
          .partitioner(&quot;step-partition&quot;, partitioner)
              .gridSize(2)
                  .step(stepTwo)
              .taskExecutor(taskExecutor)
      .build();
  }
  </code></pre>
  <pre><code>@Bean(name = &quot;step-two&quot;)
  public Step stepTwo(@Autowired JdbcPagingItemReader&lt;Product&gt; pagingItemReader) {
      return stepBuilderFactory.get(&quot;step-two&quot;)
          .&lt;Foo, Foo&gt;chunk(10)
              .reader(pagingItemReader)
                  .processor(itemProcessor)
              .writer(itemWriter)
      .build();
  }
  </code></pre>
  <pre><code>@Bean
  public SimplePartitioner partitioner() {
      SimplePartitioner partitioner = new SimplePartitioner();
      partitioner.partition(10);
  
      return partitioner;
  }
  </code></pre>