Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky test in reactive-messaging-hibernate-orm #29433

Merged
merged 1 commit into from
Jan 31, 2023

Conversation

ozangunalp
Copy link
Contributor

I think when the hibernate orm state store test has been added to that IT the test using Emitter in @Transactional method reproduced the issue in #21948 .

To fix the flaky test the method using transactional no longer returns a completion stage.

The original issue is still to investigate.

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spotted a small thing.

Now, tbh, I have no real idea of what you're doing :).

@ozangunalp
Copy link
Contributor Author

@Sanne @cescoffier to give more context: This test was stable before I add the other one involving Hibernate transactions.

So this is the code that started to behave flaky:

@Incoming("fruits-in")
@Transactional
public CompletionStage<Void> persist(Message<Fruit> fruit) {
    fruit.getPayload().persist();
    return emitter.sendMessage(fruit).subscribeAsCompletionStage();
}

I verified that the completion stage completes on the same Vert.x context (blocking) as the method call. But then I cannot reproduce it locally :)

@Sanne
Copy link
Member

Sanne commented Nov 23, 2022

@ozangunalp thanks! I wonder if it could relate to #29159

@ozangunalp
Copy link
Contributor Author

The MutinyEmitter makes sure that the caller Vert.x context is preserved when the send Uni returns, but in this case the thread won't be the same, as it'll return on the event loop instead of the worker thread.

Looking at the TransactionalInterceptorBase, when handling the CompletionStage return type, the transaction will end in another thread, (but same Vert.x context if it makes any difference). It seems to handle the case and install the right transaction to end.

@ozangunalp
Copy link
Contributor Author

The test is still flaky

@quarkus-bot

This comment has been minimized.

@ozangunalp
Copy link
Contributor Author

Trying to remove the named persistence-unit configured to use with the checkpointing state store in the test.

@quarkus-bot

This comment has been minimized.

@ozangunalp
Copy link
Contributor Author

First run was green. Triggered a re-run

@quarkus-bot

This comment has been minimized.

@ozangunalp
Copy link
Contributor Author

The test is still flaky. I'll disable the test in this PR.

I don't think that I am doing anything wrong on HibernateOrmStateStore, maybe it reproduces that issue more consistently - I still cannot reproduce it locally. @Sanne can you take a look when you have some time?

@gsmet
Copy link
Member

gsmet commented Nov 24, 2022

Let's keep this PR open as a basis to dig into this issue but I created a simple PR that we can merge right away there: #29478 .

@gsmet gsmet marked this pull request as draft November 24, 2022 18:27
@ozangunalp ozangunalp force-pushed the fix_hibernate_orm_state_store branch 2 times, most recently from 53a9f4e to dd55793 Compare December 2, 2022 11:38
@ozangunalp ozangunalp force-pushed the fix_hibernate_orm_state_store branch 2 times, most recently from a03e1ec to cb21e65 Compare December 7, 2022 08:56
@ozangunalp ozangunalp marked this pull request as ready for review December 7, 2022 16:39
@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@ozangunalp
Copy link
Contributor Author

@gsmet @cescoffier I think we can take this in. I added a note on the Kafka guide example
The issue was sending the Hibernate entity object to Kafka during the transaction. It will run Kafka serialization on the sender thread and somehow Hibernate is not happy about it.

@quarkus-bot

This comment has been minimized.

Uses DTO for sending Kafka records

Separate PUs for fruit and people entities
@gsmet gsmet merged commit e6dc19d into quarkusio:main Jan 31, 2023
@quarkus-bot quarkus-bot bot added this to the 2.17 - main milestone Jan 31, 2023
@github-actions
Copy link

🙈 The PR is closed and the preview is expired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants