feat: proactively probe database on Auto-IAM refresh to update MCP tokens - #1150
Draft
hessjcg wants to merge 2 commits into
Draft
feat: proactively probe database on Auto-IAM refresh to update MCP tokens#1150hessjcg wants to merge 2 commits into
hessjcg wants to merge 2 commits into
Conversation
Code review comments addressed: - Respect the IP settings in connection configuration (WithRefreshAheadIPType / connectionType) rather than probing all available IPs - Use configured refreshTimeout for probe context timeout
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.
Fixes GoogleCloudPlatform/cloud-sql-proxy#2553
When connecting to Cloud SQL for PostgreSQL with Managed Connection Pooling (MCP) enabled, the server-side MCP caches the IAM OAuth2 access token passed during connection establishment. Because IAM tokens expire after 1 hour, pooled backend sessions retain stale tokens and cause intermittent authentication failures (SQLSTATE 08P01).
This change adds a proactive connection test / probe during the background credential refresh cycle when Auto-IAM authentication is enabled. Immediately following a successful certificate refresh, the connector opens a TCP socket to the instance (port 3307), performs the TLS handshake to propagate the newly minted IAM token to the server's MCP daemon, and immediately closes the socket.