Skip to content

feat: proactively probe database on Auto-IAM refresh to update MCP tokens - #1150

Draft
hessjcg wants to merge 2 commits into
mainfrom
mcp-iam-token-refresh
Draft

feat: proactively probe database on Auto-IAM refresh to update MCP tokens#1150
hessjcg wants to merge 2 commits into
mainfrom
mcp-iam-token-refresh

Conversation

@hessjcg

@hessjcg hessjcg commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intermittent IAM Authentication Failure (SQLSTATE 08P01) when using Managed Connection Pooling (MCP)

1 participant