cloud-sql-jdbc-socket-factory icon indicating copy to clipboard operation
cloud-sql-jdbc-socket-factory copied to clipboard

Automatically configure and fail-over connections using DNS

Open hessjcg opened this issue 1 year ago • 2 comments

Feature Description

The java connector may be configured to connect to a Cloud SQL instance using a DNS name.

When the JDBC connection properties does not contain the cloudSqlInstance property, the connector will attempt to use the hostname from the JDBC URL to resolve name using DNS. The connector will query the local DNS for a TXT record. The TXT should contain an instance name matching that DNS name. The connector will use the instance name from the TXT record to connect to the Cloud SQL instance.

The connector will periodically query that DNS. If the instance name in the DNS record changes, the connector will terminate all open connections to the old instance. Then, it will reconfigure itself to open connections to the new instance.

This enables several DNS-related features by allowing configuration through DNS.

Users can configure their database clients using the domain name instead of the instance name. Users can fail-over database clients when they change the DNS entry for the database instance.

This is the Java implementation of https://github.com/GoogleCloudPlatform/cloud-sql-go-connector/issues/842

hessjcg avatar Jul 18 '24 16:07 hessjcg

Does this prevent split brain?

derek-gfs avatar Oct 16 '24 19:10 derek-gfs

Does this prevent split brain?

@derek-gfs Thanks for the question! 😄

@hessjcg who is driving DR support here is OOO until next week, but will respond here when he is back.

jackwotherspoon avatar Oct 16 '24 19:10 jackwotherspoon

Hi All - Any updates on the implementation of this?

Since write endpoints are now in preview, I am eager to give this a try.

derek-gfs avatar Nov 26 '24 13:11 derek-gfs

Hi All - Any updates on the implementation of this?

Since write endpoints are now in preview, I am eager to give this a try.

@derek-gfs Thanks for showing your interest here! We really appreciate it 😄

I believe @hessjcg will be picking back up this work in the coming week or two and getting these PRs across the line.

We are still waiting on a backend change to fully roll out before the full support of the feature in the Connectors will be possible.

jackwotherspoon avatar Nov 27 '24 21:11 jackwotherspoon