Replies: 1 comment 2 replies
-
Not sure exactly why something like this is happening but you should avoid the operators that are canceling the upstream when using R2DBC, instead of using I have reported some of the behavior that I found weird when using R2DBC pgjdbc/r2dbc-postgresql#428 Maybe there is a way to "fix it" on our side, PRs are welcome 😄 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have spotted a weird behavior related to R2DBC transaction handling in micronaut-data. It seems that in some cases transaction commit can be done after
R2dbcOperations#withTransaction
(or method annotated with@Transactional
) emits theonComplete
signal, which obviously doesn't look like a desired behavior.The easiest way to observe the issue is with additional logs in the micronaut-data code. Here is the commit in my fork with all the necessary changes and a test to showcase the issue: kstrek@244432f
Basically, the test is a simplest possible db insert wrapped in a transaction (it's based on the code found in
BookControllerTest.java
):Additional logs are introduced in
DefaultR2dbcRepositoryOperations
after the the commit completes and after the connection is closed.Logs produced by this test are as follows:
As you see,
Transaction completed
message is printed beforeSuccessfully committed transaction for DataSource default.
(andSuccessfully closed connection for DataSource: default
which seems related). Also, another weird thing is that connection is being closed (Closing Connection for DataSource
) before commit is finished.What's interesting, when the publisher inside the
withTransaction
is an empty mono (i.e. doesn't emit onNext), like this:then everything works as expected:
Am I doing something wrong here? Should I report a bug? I can't find any docs suggesting that publisher wrapped with
withTransaction
is required to return empty mono. I tried to debug the issue but it seems to involve some weird cancellation logic, which is slightly beyond my comprehension of reactor 😉 . Any help appreciated.Beta Was this translation helpful? Give feedback.
All reactions