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

High availability cluster functionality #474

Closed
wants to merge 1 commit into from

Conversation

kressi
Copy link
Contributor

@kressi kressi commented Dec 28, 2021

It looks like #203 has been abandoned. Nevertheless, I could use HA cluster functionality. I am aware of #250 which got closed again. However, almost another year has passed without any visible activity. So, I am hoping this MR will be accepted.

I got stuck and would appreciate some guidance with following issues brought up by @mp911de.

@mp911de
Copy link
Collaborator

mp911de commented Jan 3, 2022

This looks pretty exciting. I will have to take a deeper look in the next days.

@mp911de mp911de self-assigned this Jan 3, 2022
@mp911de
Copy link
Collaborator

mp911de commented Jan 11, 2022

From a planning perspective, while I'd love to include the PR into our 0.9 GA release, I think it doesn't work out with our timing to ship 0.9 GA today. We will have to postpone it to one of the maintenance releases.

@mp911de mp911de added the type: enhancement A general enhancement label Jan 11, 2022
@mp911de
Copy link
Collaborator

mp911de commented May 17, 2022

I started looking today at the pull request and figured that I'm not able to rebase the PR. Can you please squash all commits into a single one and rebase the PR onto main, please?

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label May 17, 2022
@harishvashistha
Copy link

@kressi Can you please support to move these changes to official master branch of this library? We are eagerly waiting for your changes in official release.

@harishvashistha
Copy link

@mp911de @kressi can you help pushing this feature to official release of r2dbc library.

@kressi
Copy link
Contributor Author

kressi commented May 27, 2022

@harishvashistha, @mp911de, I will start working on it

kressi added a commit to kressi/r2dbc-postgresql that referenced this pull request May 28, 2022
kressi added a commit to kressi/r2dbc-postgresql that referenced this pull request May 28, 2022
kressi added a commit to kressi/r2dbc-postgresql that referenced this pull request May 28, 2022
@harishvashistha
Copy link

@kressi thanks for handling this on priority. It is a nice gesture. @mp911de please help us to take this work into official release.

@mp911de
Copy link
Collaborator

mp911de commented May 30, 2022

Thanks a lot @kressi, I plan to wrap up the cluster support this week. I expect that the next release will be a milestone of 1.0 to allow folks to try out this feature before we ship it with a GA release.

@harishvashistha
Copy link

@mp911de that would be great. Waiting eagerly on this.

@mp911de mp911de removed the status: waiting-for-feedback We need additional information before we can continue label May 30, 2022
@mp911de mp911de added this to the 1.0.0.RELEASE milestone May 30, 2022
@mp911de
Copy link
Collaborator

mp911de commented May 30, 2022

Not sure whether High availability cluster functionality is a bit misleading as the title of this change since what the change introduces is the detection of roles from a set of hosts and picking one host to connect to that works.

In any case, I like the outcome here and likely in the future, we could maintain active connections along with an improved host selector that applies on a per-transaction/per query basis so that e.g. read-only transactions might run directly on a replica instead of the master node.

@mp911de
Copy link
Collaborator

mp911de commented May 31, 2022

I polished up the code a bit and refactored the code to align with ConnectionFunction and ConnectionStrategy concepts where ConnectionFunction is a low-level connect-to-host facility and the strategy can make use of connection functions to connect to a particular target server.

I still need to work on the tests to get an idea whether all of this is correct but things look pretty decent now.

mp911de pushed a commit that referenced this pull request Jun 1, 2022
We now provide a failover connectivity model supporting host selection from an array of endpoints.

[resolves #120][#474][#203]
@mp911de mp911de closed this in 2e0969e Jun 1, 2022
@mp911de
Copy link
Collaborator

mp911de commented Jun 1, 2022

Thanks, everyone for your contribution. That's merged and polished now.

@mp911de mp911de mentioned this pull request Jun 1, 2022
@harishvashistha
Copy link

harishvashistha commented Jun 1, 2022

@mp911de Thanks, great news. which version of r2dbc-postgressql jar has this feature? or soon you're going to make something available?

@mp911de
Copy link
Collaborator

mp911de commented Jun 1, 2022

This feature will be shipped with 1.0 M1. You can verify the functionality already with the version 1.0.0.BUILD-SNAPSHOT and report back any issues. That way, we can find out whether things are working for you before we ship a milestone release.

@alexander-mikhailov
Copy link

alexander-mikhailov commented Sep 25, 2023

@mp911de @kressi @harishvashistha
Is there a way to see in logs that plugin does work, like a line indicating a host was changed or similar?

One more question is:
Does the plugin support io.r2dbc.pool.ConnectionPool factory?

val connectionFactoryOptionsBuilder = ConnectionFactoryOptions.builder()
            .option(ConnectionFactoryOptions.HOST, "host1,host2")
            .option(ConnectionFactoryOptions.USER, "user")
            .option(ConnectionFactoryOptions.PASSWORD, "pwd")
            .option(ConnectionFactoryOptions.LOCK_WAIT_TIMEOUT, properties.lockTimeout)
            .option(ConnectionFactoryOptions.STATEMENT_TIMEOUT, properties.statementTimeout)
            .option(HOST_RECHECK_TIME, Duration.ofMillis(500))
            .option(ConnectionFactoryOptions.PROTOCOL, FAILOVER_PROTOCOL)
            .option(ConnectionFactoryOptions.DATABASE, "db")
        
val config = PostgresqlConnectionFactoryProvider.builder(connectionFactoryOptionsBuilder.build()).build()
    
val postgresqlConnectionFactory = PostgresqlConnectionFactory(config)
            
val cpc = ConnectionPoolConfiguration.builder(postgresqlConnectionFactory).build()

return ConnectionPool(cpc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Postgresql multi-host failover functionality
4 participants