Skip to content

readiness failed: context deadline exceeded: how to investigate what the root cause is #1645

Description

@mweibel

Question

We upgraded recently to v2.0.0 of cloud-sql-proxy and with that also enabled http health checks. We have cloudsql-proxy deployed as a sidecar to roughly 15 applications in a GKE cluster running v1.23.14-gke.1800.

The sidecar is configured the same way:

  - name: cloudsql-proxy
    image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.0.0
    command:
      - /cloud-sql-proxy
    args:
      - <instance>
      - --auto-iam-authn
      - --credentials-file=/secrets/cloudsql/credentials
      - --http-port=9080
      - --http-address=0.0.0.0
      - --health-check
      - --structured-logs
      - --max-connections=25
      - --max-sigterm-delay=30s
    startupProbe:
      httpGet:
        path: /startup
        port: 9080
      periodSeconds: 30
      timeoutSeconds: 5
    readinessProbe:
      httpGet:
        path: /readiness
        port: 9080
      periodSeconds: 30
      timeoutSeconds: 5
    livenessProbe:
      httpGet:
        path: /liveness
        port: 9080
      periodSeconds: 30
      timeoutSeconds: 5
    volumeMounts:
      - name: database-credentials
        mountPath: /secrets/cloudsql
        readOnly: true

Two types of applications:

The apps all connect to the same Cloud SQL instance (PostgreSQL 13.7, vCPUs: 2, Memory: 7.5 GB, configured with 400 connection limit but peak connections 114 in the last 24h). System insights don't show high CPU or memory usage but all rather low. Ingress/Egress is a bit high (~2-3Mbit/s) - this we're working on anyway.

All apps have connection pool limits defined and we have an additional, slightly higher limit on the cloudsql-proxy itself.

In the last 24h we had 2'892 readiness failed errors ([Health Check] Readiness failed: refresh failed: context deadline exceeded) and 43 connection reset by peer (connection aborted - error reading from client: read tcp 127.0.0.1:5432->127.0.0.1:57628: read: connection reset by peer).

There is no real regularity in the log intervals which would point to certain scheduled queries to run, plus we reduced some of those to the minimum (~3 analytics queries running every hour now).

What we're trying right now:

  • Remove max-connections flag from cloudsql-proxy to see if that makes any difference (also we know the pool limits of the apps work so it's not that)
  • Switch over to private IP instead of public IP - though I'm not sure if that has any effect TBH

Questions:

  • Is there anything else we can do to investigate what is happening?
  • Should we set resource requests/limits on cloudsql-proxy sidecar? Our CloudSQL sidecars don't have resource requests/limits defined, but all our apps have I took some configuration info from the cloud-sql-proxy operator and I think there the resource requests/limits are not configured too
  • Should we switch to a central CloudSQL proxy instance with PGBouncer in front instead?

Thanks!

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions