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

Unable to run test with debezium #4557

Closed
dcdh opened this issue Oct 14, 2019 · 2 comments
Closed

Unable to run test with debezium #4557

dcdh opened this issue Oct 14, 2019 · 2 comments
Labels
kind/question Further information is requested

Comments

@dcdh
Copy link
Contributor

dcdh commented Oct 14, 2019

Describe the bug
This commit add the ability to detect if a blocking op is performed in the IO thread.

My POC ensure that we can do testing with debezium.
However it fails because the kafka consumer should be executed in the same thread than the test and so I am unaware to make entity request in test and also in kafka consumer.

Expected behavior
I would like to do in test:

  1. save an entity using the entity manager ;
  2. pool the entity manager multiple time (using awaitability) until the consumer do his job (by muting an entity in database).

Actual behavior
When the test is keep running (in awaitibility await method) and the kafka consumer execute a database request using the entity manager this exception is thrown:

2019-10-14 20:41:04,995 ERROR [com.dam.san.GiftConsumer#onMessage] (vert.x-eventloop-thread-0) The method com.damdamdamdeo.santa.GiftConsumer#onMessage has thrown an exception: java.lang.IllegalStateException: You have attempted to perform a blocking operation on a IO thread. This is not allowed, as blocking the IO thread will cause major performance issues with your application. If you want to perform blocking EntityManager operations make sure you are doing it from a worker thread.
        at io.quarkus.hibernate.orm.runtime.entitymanager.TransactionScopedEntityManager.checkBlocking(TransactionScopedEntityManager.java:84)
        at io.quarkus.hibernate.orm.runtime.entitymanager.TransactionScopedEntityManager.createQuery(TransactionScopedEntityManager.java:315)
        at io.quarkus.hibernate.orm.runtime.entitymanager.ForwardingEntityManager.createQuery(ForwardingEntityManager.java:142)
        at com.damdamdamdeo.santa.GiftConsumer.onMessage(GiftConsumer.java:25)
        at com.damdamdamdeo.santa.GiftConsumer_ClientProxy.onMessage(GiftConsumer_ClientProxy.zig:135)
        at com.damdamdamdeo.santa.GiftConsumer_SmallryeMessagingInvoker_onMessage_8a2a58316cee48b845e8e88cd5a3d9a98cc9dcf4.invoke(GiftConsumer_SmallryeMessagingInvoker_onMessage_8a2a58316cee48b845e8e88cd5a3d9a98cc9dcf4.zig:48)

To Reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/dcdh/poc-quarkus-persistence.git
  2. git checkout debezium
  3. start containers by executing run_container.sh (warning it will kill and remove all containers)
  4. run test using this command line mvn clean test

Configuration
In the poc.

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a or ver: Linux arch-anywhere 5.3.1-arch1-1-ARCH Switch to the Maven distributed copy of the SubstrateVM annotations #1 SMP PREEMPT Sat Sep 21 11:33:49 UTC 2019 x86_64 GNU/Linux
  • Output of java -version:
    openjdk version "1.8.0_202"
    OpenJDK Runtime Environment (build 1.8.0_202-20190206132807.buildslave.jdk8u-src-tar--b08)
    OpenJDK GraalVM CE 1.0.0-rc16 (build 25.202-b08-jvmci-0.59, mixed mode)
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 0.24.0

Additional context
If you run multiple time the test without restarting the kafka container the kafka event may not be consumed.

Workaround
By injecting a new instance of EntityManager in the kafka consumer it works :)
The workaround is in the branch debezium-workaround.
edit: I've rework the branch and I produce multiple EntityManager instance using Dependent scope.

@dcdh dcdh added the kind/bug Something isn't working label Oct 14, 2019
dcdh added a commit to dcdh/event-data-spreader that referenced this issue Oct 15, 2019
@Sanne
Copy link
Member

Sanne commented Nov 7, 2019

@gunnarmorling Could you have a look, or otherwise make sure this is taken care of? Thanks!

@dcdh
Copy link
Contributor Author

dcdh commented Jan 15, 2020

I have fixed it by returning a CompletionStage.supplyAsync cf this commit

I guess the rule would be to always return an CompletionStage.supplyAsync when processing data.

I close it. Thanks.

@dcdh dcdh closed this as completed Jan 15, 2020
@gsmet gsmet added kind/question Further information is requested and removed kind/bug Something isn't working labels Jan 15, 2020
dcdh added a commit to dcdh/event-data-spreader that referenced this issue Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants