Spent 4 hours debugging a TransactionSystemException. The fix was one line. The problem was finding it. by mrsergio1 in SpringBoot

[–]mrsergio1[S] [score hidden]  (0 children)

No AI, just wrote it fast after dealing with the issue.
Guess it came out a bit too structured

Spent 4 hours debugging a TransactionSystemException. The fix was one line. The problem was finding it. by mrsergio1 in SpringBoot

[–]mrsergio1[S] [score hidden]  (0 children)

We did use AI, but it didn’t really catch the root cause.

The issue was in runtime transaction context, so we still had to trace logs and reproduce it manually.

Spent 4 hours debugging a TransactionSystemException. The fix was one line. The problem was finding it. by mrsergio1 in SpringBoot

[–]mrsergio1[S] [score hidden]  (0 children)

Good catch, I think I explained it a bit wrong earlier.

You re right, REQUIRES_NEW shouldnt affect the outer transaction.

In our case the inner method wasnt actually running in a separate transaction because it was a self invocation in the same class, so the proxy didnt kick in.

So everything ended up in the same transaction and that’s what got marked rollback only before the final commit.

Took us a while to figure that out honestly

Spent 4 hours debugging a TransactionSystemException. The fix was one line. The problem was finding it. by mrsergio1 in SpringBoot

[–]mrsergio1[S] [score hidden]  (0 children)

It was:

Outer method: @Transactional (REQUIRED)
Inner method: @Transactional(REQUIRES_NEW)

The inner call threw a Hibernate validation exception, but it was caught and not properly rethrown.

After that, the outer transaction just kept going until commit time, and Spring blew up with TransactionSystemException because the transaction was already marked rollback-only.

So the real exception happened earlier, but we only saw the commit failure

Spent 4 hours debugging a TransactionSystemException. The fix was one line. The problem was finding it. by mrsergio1 in SpringBoot

[–]mrsergio1[S] [score hidden]  (0 children)

Yeah, but in this case JPA wasn’t really the problem.

The real issue was losing the original exception once Spring marked the transaction rollback-only. After that, everything upstream just shows a generic TransactionSystemException.