-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Postgresql with Panache + Kafka consumer results in HR000061: Session is currently connecting to database #23804
Comments
I can also reproduce the issue with 2.7.2 |
With 2.7.3 panache is still failing, but pure hibernate is also failing now on the first message with
|
This is expected, kafka does not use safe duplicated context yet. We are working on that. |
In 2.6.2 is working fine. 2.7.x doesn't work |
With some sort of "working". It was actually not working correctly as the session was stored and shared between unrelated processing. |
We have the same HR000061 issue with Panache + Smalltye-amqp + postgresql but only after the second message consumed . |
@cescoffier Hey, we are facing the same issue when we upgraded from 2.6.x to 2.7.x. Any workaround until the kafka safe duplicated context is implemented? Thanks |
@eldimious As far as I can tell 2.8.0.CR1 / 2.8.0.Final should implement the duplicated context handling for kafka + pure hibernate reactive (no panache). Panache is still failing with the original error though. |
@RuggeroDAlo thanks for the info. Hm weird, as we have tried 2.8.0.CR1 + io.quarkus:quarkus-hibernate-reactive and the problem remains: |
@eldimious Strange, I tried with the following code on |
Yes, this approach should work. Note that we have fixed the upstream issues (so Kafka records are now processed in their own duplicated context) |
Ηey @RuggeroDAlo and @cescoffier thanks for your info. https://github.com/arconsis/Eshop-EDA/blob/main/v2/services/PaymentService/src/main/kotlin/com/arconsis/data/payments/PaymentsRepository.kt#L26 Our impl is a bit different as first we "simulate" a external REST call using |
That is expected. Your delay switches to a worker thread and so you are not on the duplicated context anymore. |
@cescoffier is this fixed? |
Yes! |
@gsmet |
I also tested with 999-SNAPSHOT and I also don't think this is fixed. There was a similar issue with graphql that was fixed #21111, but panache still seems broken. |
@RuggeroDAlo |
@cdmikechen Yes I think this should still be open, but I can't reopen it, @cescoffier should I open another issue? |
Yes please, with a reproducer as this one works for me. |
Strange @cescoffier , I just reproduced with the repo linked in the issue
Maybe you sent messages to the hibernate reactive queue (wordsin-hibernate) and not the panache queue (wordsin-panache)? |
hum, weird, I will have another look. |
@RuggeroDAlo |
In my case, I have a service that handles many |
@cdmikechen luckily for me my use of panache was very limited, I just stopped using it and use hibernate reactive. |
Is there any progress on this issue? I have a similar setup running with panache reactive along with postgres and kafka.
After a while I'm getting a timeout:
|
I do not believe @ReactiveTransactional works with reactive messaging. It's specific to RestEasy reactive. You will. We'd to handle the transaction your self for now. |
I tried it this way without success:
I can consume 3 messages. The fourth message fails with the exception mentioned above. |
@tobi-quarkus-coder the issue is that the icomming message is not acked, you need to call @cescoffier we definitly need to document somewhere how to use reactive messaging with transaction as it's a very common use case: both with blocking and reactive one. |
@loicmathieu I tried the following without any effect.
|
@tobi-quarkus-coder i had the same problem and I used the following workaround.
|
@cbianco Thx for the workaround. Yeah this works but bypasses Panache unfortunately. I'd really like to use the full stack including Panache. In my real world scenarios I'll have to perform more complex queries and use the simplicity of Panache for it. |
The problem comes from |
@cescoffier Thanks for this! I adapted the code a little and made it a bit more "Panache-style":
With this, I don't have to inject the Mutiny Session my own, it'll be handled under the hood. |
I think the way we need to suggest in the doc is to use the |
@ozangunalp I tried it and got the same timeout Exception. This is what I tried:
|
Hum, doing the persist on the session works. If I use Panache it doesn't. Works:
Doesn't work:
|
Try to add |
Yes, this works:
I was wondering as @ozangunalp was suggesting to use sessionFactory which handles closing the session on it's own. Couldn't get this working. |
@tobi-quarkus-coder Thanks for the feedback! That's what I suspected. |
Is there any plan to fix the original issue so that Panache can be used easily? Or is it basically impossible? |
Since 2.13.0 version of Quarkus, using the session.withTransaction then closing it as per the documentation is not working anymore. Throwing multiple exceptions:
The migration guide indicates: Prior to Quarkus 2.13, the Reactive Messaging consuming methods were called with an active CDI request context, inadvertently propagated, and were never terminated. Quarkus corrects this behaviour and makes sure the request context is not activated unnecessarily on message consuming methods. Code relying on the presence of the RequestScoped beans might need to start a request scope explicitly; for example, using @ActivateRequestContext annotation on the message consuming method. Adding @ActivateRequestContext does not seem to fix the issue. |
Please open a new issue with a reproducer. |
Hi @cescoffier, yes created it #29019 |
Any update on this? I've stumble upon this thread and found it very helpful and useful and I got it working with reactive hibernate, just not with Panache. I tried to call session.close but when I do when using Panache, I get the error Tried with:
I think what might be part of the confusion is wether panache or reactive-panache is being used. I think the latter is the problem here. Any tips? |
Describe the bug
After 4 calls to panache in a reactive kafka channel method the following error is raised:
This doesn't work:
This does:
I've created a reproducer, this only happens when using panache with kafka on 2.7.1, pure hibernate reactive with kafka on 2.7.1 works, panache with a reactive endpoint on 2.7.1 works, 2.7.0 works for everything.
I think these may be related: #23736 , #23278
Expected behavior
A kafka consumer should be able to make more than 4 calls to panache
Actual behavior
After the 4th call to panache in a kafka consumer all queries fail.
How to Reproduce?
quarkus:dev
kafka-console-producer.sh --topic wordsin-panache --bootstrap-server localhost:PORT
Output of
uname -a
orver
5.13.0-28-generic #31-Ubuntu SMP Thu Jan 13 17:41:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
Java version: 11.0.13, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
GraalVM version (if different from Java)
NA
Quarkus version or git rev
2.7.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Additional information
No response
The text was updated successfully, but these errors were encountered: