spring-projects / spring-projects/spring-batch

Getting error with Springboot 3.4.1 while executing batch jobs

Open
#4,744 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-reporter type: bug
Dominant language
Java
Stars
3k
Forks
2.5k
Avg merge
6d 53m
Merged PRs (30d)
3

Description

Bug description
Getting error with Springboot 3.4.1 while executing batch jobs

Error Message:
Command failed with error 251 (NoSuchTransaction): 'Transaction with { txnNumber: 24 } has been aborted.' on server pl-0-eu-west-1.3dhx9.mongodb.net:1041. The full response is {"errorLabels": ["TransientTransactionError"], "ok": 0.0, "errmsg": "Transaction with { txnNumber: 24 } has been aborted.", "code": 251, "codeName": "NoSuchTransaction", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1735790456, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "sKYXYVX+BZTVEOMUocGi7Cm8t2A=", "subType": "00"}}, "keyId": 7434572047025438725}}, "operationTime": {"$timestamp": {"t": 1735790456, "i": 1}}}

Possible Cause: The error might be due to the transaction timeout or multiple write operations causing the transaction to abort.

Reference: TransientTransactionError/NoSuchTransaction issue on long/large write operations using Mongoose transactions

Environment

  • Spring Batch version: 5.2.0
  • Java version: 21
  • Database: Mongo Atlas

Steps to reproduce

  1. Execute the batch job.
  2. The job should sync all data.
  3. The job aborts in between, possibly due to multiple write operations.

Expected behavior
The batch job should execute and sync all data without aborting.

Minimal Complete Reproducible example
Fails at: mongoTemplate.findAndModify(query, update, SelectorModel.class, CollectionNames.SELECTORS);

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

Begin with the reported mongoTemplate.findAndModify call and run the batch job using the stated Spring Batch, Java, and Mongo Atlas environment. Investigate the NoSuchTransaction and TransientTransactionError details to isolate why the job aborts; done means the full sync completes without aborting and the cause and verification are recorded.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mongodb, spring-boot
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.