GoogleCloudPlatform / cloud-spanner-r2dbc

R2DBC driver for Google Cloud Spanner
Apache License 2.0
57 stars 29 forks source link

It is not possible to use the spring @Transactional anotation #684

Closed filipenfst closed 1 year ago

filipenfst commented 1 year ago

If i try to use the @Transactional annotation from spring i get the error

Could not open R2DBC Connection for transaction
org.springframework.transaction.CannotCreateTransactionException: Could not open R2DBC Connection for transaction
    (Coroutine boundary)
    at com.example.spannercontexterror.R2DBCSpannerErrors$transactionFailTest$1.invokeSuspend(R2DBCSpannerErrors.kt:65)
Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open R2DBC Connection for transaction
    at app//org.springframework.r2dbc.connection.R2dbcTransactionManager.lambda$doBegin$5(R2dbcTransactionManager.java:234)
    Suppressed: The stacktrace has been enhanced by Reactor, refer to additional information below: 
Assembly trace from producer [reactor.core.publisher.MonoError] :
    reactor.core.publisher.Mono.error(Mono.java:298)
    org.springframework.r2dbc.connection.R2dbcTransactionManager.lambda$doBegin$5(R2dbcTransactionManager.java:236)

To reproduce the error you can use the test transactionFailTest that you can find here https://github.com/filipenfst/spanner-context-error/blob/master/src/test/kotlin/com/example/spannercontexterror/R2DBCSpannerErrors.kt

The issue is cause by the begingTransaction method on the SpannerClientLibraryConnection class

  @Override
  public Publisher<Void> beginTransaction(TransactionDefinition definition) {
    return Mono.error(new UnsupportedOperationException());
  }
meltsufin commented 1 year ago

Is it supposed to work with Spring Boot 2.7 and Spring Data R2DBC 1.5.6.? I don't see it documented as supported.

filipenfst commented 1 year ago

I think it should be supported because there is not any documentation saying that it is not supported. How would i know that it does not work before starting using it if it is not documented? If that support is not implemented soon i will have to throw out 4 months of work and rewrite my service with any db that does not comes from google. That is a really bad position that you guys put me.

meltsufin commented 1 year ago

It's in the release notes: https://github.com/GoogleCloudPlatform/cloud-spanner-r2dbc/releases

filipenfst commented 1 year ago

That information should be on the main project page https://github.com/GoogleCloudPlatform/cloud-spanner-r2dbc and here https://cloud.google.com/spanner/docs/use-oss-r2dbc not "hidden" only on the release notes. Those are what people first look at. But anyway, is there a plan to implement compatibility with spring? And what is the target date for that?

meltsufin commented 1 year ago

Looks like a duplicate of #314.

jainsahab commented 1 year ago

@burkedavison @meltsufin Should we close this now, since #738 is addressing it?

meltsufin commented 1 year ago

Fixed in #738.