fix: only keep track of sockets opened using domain name#2130
Merged
Conversation
Collaborator
Author
|
@hessjcg do you mind adding a unit test to verify that the Connector using an instance connection name does not add to the socket list? |
97bc92c to
959c877
Compare
hessjcg
approved these changes
Mar 27, 2025
959c877 to
b39440d
Compare
Collaborator
Author
|
LGTM, thanks for the tests! ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The list
socketson theMonitoredCacheshould only keep track ofsockets opened for connections using a domain name.
It should not keep track of all sockets for regular connections.
This is what it is currently doing:
cloud-sql-jdbc-socket-factory/core/src/main/java/com/google/cloud/sql/core/Connector.java
Line 141 in a5329ac
Sockets are only removed from the list if the connections were made using a domain name:
cloud-sql-jdbc-socket-factory/core/src/main/java/com/google/cloud/sql/core/MonitoredCache.java
Lines 92 to 96 in a5329ac
Thus for sockets not using a domain name and using the default instance connection name pattern, the sockets list will continue to grow and grow without being cleaned up.
This PR adds the proper check to gate adding to the
socketslist for only connections using a domain name.Fixes #2129