r2dbc-mysql
r2dbc-mysql copied to clipboard
[feature]Supports Multiple host configuration.
Is your feature request related to a problem? Please describe. The probleme is that tve driver doesn't support multiple host configuration
Describe the solution you'd like support multiple hosts configuration, for example: r2dbc:mysql//host1,host2/db
Hello, @tabdelbari. Thank you for bringing this feature request to our attention. I'll be taking up the task to work on implementing multiple host configurations.
Considering that the R2DBC SPI already supports multiple hosts, it would be beneficial for our project to have this feature as well.
Similar requests have been made in the past, and there's a clear demand for this feature
- https://github.com/mirromutth/r2dbc-mysql/issues/169
- https://github.com/mirromutth/r2dbc-mysql/issues/183
reference
- https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-multi-host-connections.html
- https://r2dbc.io/spec/1.0.0.RELEASE/spec/html/#overview.connection.url
Thank you so much @jchrys
It requires following tasks:
- Connection strategy when creating the connection
- https://dev.mysql.com/doc/connector-j/en/connector-j-multi-host-connections.html
- https://mariadb.com/kb/en/failover-and-high-availability-with-mariadb-connector-j
- DNS SRV Records support: https://dev.mysql.com/doc/refman/8.0/en/connecting-using-dns-srv.html
- Reconnection strategy:
autoReconnect/maxReconnects/reconnectAtTxEnd/initialTimeoutoption. It should be reconnected only if the connection is in auto-commit mode (not in a transaction). - If
secondaryBeforeRetrySourceorrequestsBeforeRetrySourceis set, the default (no name) high availability mode will attempt to return the first host/address even if no communication exception occurs retriesAllDownoption or alternative. If the connection fails for all hosts/addresses, whether to retry them all
These we should not consider:
- Replication mode:
io.r2dbc.spi.Connectioncannot be set to a read-only connection, so this mode will always use the first host/address failOverReadOnlyoption: same reason as aboveautoReconnectForPoolsoption: force reconnect even the connection is in a transaction orautoCommit=false. Not sure it is necessaryretriesAllDowndefault value 120: Too big? The interval between all retries is 250ms, so it takes at least 30s to fail