spring-projects / spring-projects/spring-batch

Skip functionality is not working properly in MongoItemReader scenario [BATCH-2503]

Open
#1,101 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: core related-to: fault-tolerance status: waiting-for-triage type: bug
Dominant language
Java
Stars
3k
Forks
2.5k
Avg merge
6d 53m
Merged PRs (30d)
3

Description

nishant ranjan opened BATCH-2503 and commented

Skip exception class functionality is not working properly when MongoItemreader is being used.
Example:
<skippable-exception-classes>
<include class="org.springframework.core.convert.ConversionFailedException" />
</skippable-exception-classes>

Suppose 20 rows are fetched from MongoDB and at row number 15 configurable exception ".ConversionFailedException" is thrown from a custom class derived from Converter, (MessageContextReadConverter implements Converter<DBObject, MessageContext>)
. MessageContextReadConverter is set during mongoTemplate creation,.

Now, exception thrown at row number 15 is received in custom readlistener (public void onReadError(Exception ex)).

Issues:

  1. Spring batch is stuck at row number 15. It continuously calls MessageContextReadConverter and onReadError for same row number 15.
  2. skiplistener is never invoked.

Analysis:
MongoItemreader works on paging mechanism therefore skip functionality is not working.

Solution:

  1. Spring batch should provide MongoItem reader which is a cross implementation of both page and cursor techniques. Otherwise, reading each row from Mongo is huge task if data is large.

Kindly correct me if above analysis is in-correct.

I am implementing cursor based reader but again its not a solution as combination of cursor + paging is required.


Affects: 3.0.7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining the MongoItemReader paging behavior in the reported 3.0.7 scenario and the configured ConversionFailedException path. Reproduce the failure at row 15, observing repeated MessageContextReadConverter calls and onReadError without skiplistener invocation. Done means the Mongo reader applies configured skip handling without looping, with coverage for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mongodb, spring
Domain
backend, databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.