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

Ability to recreate the coreSocketFactory in CoreSocketFactory

Open meltsufin opened this issue 3 years ago • 3 comments

Currently, coreSocketFactory is a singleton, and there is no way to recreate it after it has been created.

Needed here: https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/982

meltsufin avatar Mar 14 '22 20:03 meltsufin

The change needed for this will probably be somewhat involved as there are a bunch of assumptions in the current code that the CoreSocketFactory stays the same throughout.

kurtisvg avatar Mar 14 '22 21:03 kurtisvg

@kurtisvg Can you give an example of such an assumption? Thanks!

meltsufin avatar Mar 14 '22 22:03 meltsufin

So looking at the code, it might not be as bad as I thought (I was originally thinking about replacing the Admin API client). I think the biggest problem is making sure the executor is shutdown correctly and that all of the instances in the hashmap are "cleaned up" correctly (and that the hashamp is reset)

We'll obviously need to make sure the method used to reset the instance is synchronized as well, and make sure none of the static methods rely on the codeSocketFactory directly and unsynchronized - they need to be using getInstance (we may have a couple of examples of this already).

kurtisvg avatar Mar 15 '22 02:03 kurtisvg

We're working through some significant refactoring in the core socket factory right now and will be able to revisit this request. As part of recreating the singleton, we'd be resetting the cached TLS certificates and basically starting again from scratch. Is that the expected behavior @meltsufin?

enocom avatar Mar 16 '23 16:03 enocom

Yes, having a public API to reset it is the requirement there.

meltsufin avatar Mar 16 '23 17:03 meltsufin

#1604 did not fix the whole issue.

hessjcg avatar Nov 13 '23 20:11 hessjcg