question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Event Observer BEFORE_COMPLETION transaction timeout causes strange behaviour

See original GitHub issue

Describe the bug

If you use BEFORE_COMPLETION events and a transaction timeout occurs during that event the expected rollback does not work like expected.

Expected behavior

Current transaction is rolled back.

Actual behavior

In our project (with postgresql) the commit happens despite timeout and manually calling setRollbackOnly(). (with and without the setRollbackOnly) When we attempted to reproduce this within the hibernate-orm-quickstart (with h2) project the table was deleted instead. Both behaviours should not happen.

How to Reproduce?

start mvn test of reproducer reproducer_timeout.zip

Is there anything incorrect on how we use the event? From the documentation setRollbackOnly is allowed in the BEFORE_COMPLETION event. It works without the timeout.

    @Inject TransactionSynchronizationRegistry registry;

    public void beforeCompletion(@Observes(during = TransactionPhase.BEFORE_COMPLETION) Fruit exampleEvent) {
        try
        {
            // causes timeout of transaction
            Thread.sleep(4000);
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
        // should do rollback
        registry.setRollbackOnly();
        System.out.println("done with example event");
    }

Output of uname -a or ver

MINGW64_NT-10.0-19042 w61p08 3.1.4-340.x86_64 2020-05-19 12:55 UTC x86_64 Msys

Output of java -version

java 11.0.5 2019-10-15 LTS Java™ SE Runtime Environment 18.9 (build 11.0.5+10-LTS) Java HotSpot™ 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.3.1.Final and 2.2.X

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.6.3

Additional information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
mmusgrovcommented, Nov 24, 2021

At the same time, there are a couple things that Agroal does well under the circumstances:

We agree and are switching from Transactional Driver to Agroal for standalone narayana (https://issues.redhat.com/browse/JBTM-3439), we’ve already started on the task.

0reactions
barreirocommented, Jan 3, 2022

fixed by #22442

Read more comments on GitHub >

github_iconTop Results From Across the Web

CDI events: Transactional observer called ... - Stack Overflow
I'm having problems with transactional CDI events. ... statement for MyEntity is executed twice, which causes a duplicate entry exception:
Read more >
Large configurations may cause transaction timeout events on ...
Large configurations may cause transaction timeout events on secondary blades. This issue occurs when the following condition is met:.
Read more >
JTS vs. JTA transaction timeout behavior during 2PC prepare
In my case just prepare phase takes long enough to transaction time to live expires. I can observe different behavior of JTA and...
Read more >
JTA - Oracle Help Center
The failure can be caused by either an unhealthy transaction or an ... After the Abandon Timeout period has elapsed, the WebLogic Server...
Read more >
Salesforce for Outlook sync error 'The operation is not valid for ...
TimeoutException: Transaction Timeout. ROOT CAUSE. The root cause is a SFO timeout exception due to org/user having many Unresolved Items (Contacts, Events, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found