springpostgresqlspring-data-r2dbcr2dbcr2dbc-postgresql

Spring R2DBC doesn't support multiple host/failover


I'm using spring r2dbc in my project and trying to make it work with multiple host/failover postgres topology; in other words, where the db url is like this: r2dbc:postgresql:failover://host1,host2,host3:port/

I'm using 2.7.5 version of spring boot, and get:

as a part of spring boot.
As far as I understand, this set of r2dbc libs doesn't support failover yet, since I see errors stating that such url can not be parsed.

I tried to upgrade r2dbc-postgresql-0.9.2.RELEASE to 1.0.0.RC1 but I'm getting the following error:

class java.lang.Long cannot be cast to class java.lang.Integer
(java.lang.Long and java.lang.Integer are in module java.base of loader 'bootstrap')
java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Integer
(java.lang.Long and java.lang.Integer are in module java.base of loader 'bootstrap')

as a result of executing simple delete query DELETE FROM my_table WHERE boolean_flag = $1

Which indirectly says that there is some compatibility issue in r2dbc libs. Can anyone guide me if there is working set of these libs that can work in my case or is waiting for new spring release is my only option?


Solution

  • As of Spring boot version 2.7.5 (and as far as I know any version lower then 3.0.0) there is no valid option to use postgres/spring boot/r2dbc/multiple host failover composition in your project. It is just not supported for now.

    But the good news is that it should be supported in the Spring boot 3.0.0 version which is going to be released very soon.

    Quote from Mark Paluch, the active member of r2dbc gitter:

    R2DBC 1.0 is supported by Spring Framework 6/Spring Data R2DBC 3.0 as there's a binary compatibility change between R2DBC 0.9 and 1.0