Skip to content

CompositeItemReader re-reads items on restart when a chunk spans two delegates #5591

Closed

Description

@padosol

Bug description

CompositeItemReader#update only updates the current delegate. When a chunk
spans two delegates, the state of the previous delegate is not saved. As a
result, the items the previous delegate read in that chunk are read again on
restart, even though they were already committed.

Steps to reproduce

  1. Create a CompositeItemReader with two stateful delegates: reader1
    (a1, a2, a3) and reader2 (b1, b2).
  2. Read a1, a2, then call update (end of the first chunk).
  3. Read a3, b1, then call update (end of the second chunk, which spans
    reader1 and reader2).
  4. Restart: open a new CompositeItemReader with the same ExecutionContext
    and read the remaining items.

Expected behavior

At the end of the second chunk, the state of both delegates is saved, and the
restart resumes from b2.

Delegate Items read up to the second chunk Saved state Items to read after restart
reader1 a1, a2, a3 3 items read (exhausted) none
reader2 b1 1 item read b2

Items read after restart: [b2]

Actual behavior

The restart should resume from b2, but a3 of the other delegate
(reader1) is read first. a3 was already committed in the second chunk, so
it is read twice.

Delegate Saved state Items read after restart
reader1 2 items read (saved only at the end of the first chunk) a3
reader2 1 item read b2

Items read after restart: [a3, b2]

Image

Activity

  1. added
    status: waiting-for-triage
    on Oct 13, 2026
  2. added a commit that references this issue on Nov 3, 2026
  3. added
    for: backport-to-6.0.x
    and removed
    status: waiting-for-triage
    on Nov 3, 2026
  4. added this to the 6.1.0 milestone on Nov 3, 2026
  5. added 2 commits that reference this issue on Nov 3, 2026
    5397a74
    5d00ecf
  6. added a commit that references this issue on Nov 3, 2026
    5b498f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: backport-to-6.0.xin: infrastructuretype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions