---
title: "Errors right after a Cloud Run deploy: Cloud SQL maintenance or the new revision? | Proofline"
description: "Put the instance's MAINTENANCE operation and the revision's traffic change on one timeline, then check whether the old revision failed in the same seconds."
url: https://proofline.sh/learn/cloud-sql-maintenance-or-deploy/
---

[Learning center](/learn/)

# Errors right after a Cloud Run deploy: Cloud SQL maintenance or the new revision?

Put the instance's MAINTENANCE operation and the revision's traffic change on one timeline, then check whether the old revision failed in the same seconds. Maintenance drops connections for every revision at once and ends on its own; a bad revision fails alone and keeps failing until traffic moves.

Broken dependencies The Proofline team November 23, 2026 6 min read

## Two causes that start in the same minute

A deploy at night lands inside the maintenance window more often than people expect. If you don't set a window, Cloud SQL uses a weekday window of 10 PM to 6 AM and a weekend window from Friday 10 PM to Monday 6 AM, in the instance's time zone, and maintenance usually happens once every few months. A pipeline that deploys after business hours runs inside that window. [Maintenance on Cloud SQL instances](https://cloud.google.com/sql/docs/postgres/maintenance)

Both causes produce the same application line: connections refused or reset, a pool timeout, then recovery. The new revision starts fresh instances that open new connections, so it reports errors first, which makes the deploy look guilty. Maintenance has a recorded start and end on the instance; a bad revision has none. That record is the first thing to read, and the hub's [stage table](/learn/cloud-run-cloud-sql-connection-errors/#stage) tells you which stage the errors reached.

## Check 1: was the instance in maintenance during the errors?

Every maintenance event appears in the instance's operations list as the type `MAINTENANCE`, with `startTime` and `endTime` in UTC. [Operation resource](https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/operations) · [`gcloud sql operations list`](https://cloud.google.com/sdk/gcloud/reference/sql/operations/list)

```
gcloud sql operations list --instance INSTANCE --project PROJECT \
  --filter='operationType=MAINTENANCE' --limit=5 \
  --format='table(name, operationType, status, startTime, endTime, user)'
```

The operation's span is not the outage. For Cloud SQL Enterprise edition, a maintenance update takes about 5 to 10 minutes, and the instance loses connectivity for less than 30 seconds on average; busy instances and very large datasets can see more. Enterprise Plus edition instances typically lose connectivity for less than one second during planned maintenance. The API's own description of the `MAINTENANCE` type says the instance is typically unavailable for 1 to 3 minutes, so treat the documented figures as a range. [Downtime by edition](https://cloud.google.com/sql/docs/postgres/maintenance#downtime-e) · [Operation types](https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/operations)

Read the edition and the scheduled window so you know which figure applies and whether maintenance was announced:

```
gcloud sql instances describe INSTANCE --project PROJECT \
  --format='yaml(settings.edition, settings.maintenanceWindow, scheduledMaintenance)'
```

`maintenanceWindow.hour` is in UTC; `scheduledMaintenance.startTime` holds an upcoming event. Logs Explorer also lists a `maintenance-events` log that names the instance and its scheduled start. [Instance resource](https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/instances) · [Find upcoming maintenance](https://cloud.google.com/sql/docs/postgres/maintenance)

## Check 2: did the old revision fail in the same seconds?

Find when traffic moved and which revisions reported errors. The service update that moved traffic is an Admin Activity audit entry; the errors carry `resource.labels.revision_name`. [Cloud Run audit logging](https://cloud.google.com/run/docs/audit-logging) · [Cloud Run logs](https://cloud.google.com/run/docs/logging)

```
gcloud logging read '
  logName="projects/PROJECT/logs/cloudaudit.googleapis.com%2Factivity"
  AND protoPayload.methodName=("google.cloud.run.v1.Services.ReplaceService" OR "google.cloud.run.v2.Services.UpdateService")
  AND timestamp>="START_TIME"' \
  --project PROJECT --order=asc \
  --format='table(timestamp, protoPayload.methodName, protoPayload.authenticationInfo.principalEmail)'

gcloud logging read '
  resource.type="cloud_run_revision"
  AND resource.labels.service_name="SERVICE"
  AND severity>=ERROR
  AND timestamp>="START_TIME" AND timestamp<="END_TIME"' \
  --project PROJECT --order=asc --limit=500 \
  --format='value(timestamp, resource.labels.revision_name, labels.instanceId)'
```

`--freshness` works only with descending order and filters without a timestamp, so the window goes in the filter. [`gcloud logging read`](https://cloud.google.com/sdk/gcloud/reference/logging/read)

If the previous revision still served at the time, its errors answer the question directly. If the deploy moved all traffic at once, the old revision had no requests to fail, so look at the errors' end instead: maintenance errors stop when the instance comes back, while a bad revision keeps failing.

| `MAINTENANCE` operation overlaps the errors | Old revision errors in the same seconds | Errors stop without a rollback | Reading |
| --- | --- | --- | --- |
| Yes | Yes, or it served no traffic | Yes, within minutes of `endTime` | Maintenance. Rolling back would not have helped |
| Yes | No, while it served | No | The deploy, overlapping maintenance by chance. Compare revisions as the hub describes |
| No | No | No | The deploy. Read the stage of the error |
| No | Yes | Either | Something else shared: another operation on the instance, the network or a quota. Read the full [operations timeline](/learn/cloud-sql-operations-during-incident/) |

## A worked fixture: one deploy, two nights

The fixture is illustrative. Service `orders-api` in `europe-west1` connects to `shop-prod:europe-west1:orders-db`, an Enterprise edition instance with no maintenance window set and its time zone in UTC, through Cloud Run's built-in connection. The pipeline deploys `orders-api-00018` at night, and it takes all traffic at 23:12:30 UTC.

**Night A.** The operations list shows, with the name and user columns left out:

| operationType | status | startTime | endTime |
| --- | --- | --- | --- |
| `MAINTENANCE` | `DONE` | 23:09:41 | 23:17:02 |

The error log for the window:

| Time (UTC) | Revision | Error |
| --- | --- | --- |
| 23:12:44 to 23:13:05 | `orders-api-00018` | Connection reset, then the socket refuses connections |
| 23:13:31 to 23:13:40 | `orders-api-00018` | Pool timeout on two requests |
| after 23:13:40 | none |  |

`orders-api-00017` stopped receiving requests at 23:12:30, so it could not fail. The errors last about one minute, fall inside the operation's span, and stop at 23:13:40 without any change to the service. The operation began at 23:09:41, inside the default weekday window. This fits maintenance; the deploy only coincided with it. The next useful step is a maintenance window outside the deploy schedule, which is a change to the instance, not to the service.

**Night B.** Same deploy, a different night. The operations list has no `MAINTENANCE` in the previous day. Errors from `orders-api-00018` begin at 23:12:41 and continue past 23:30. A request through the tag `prev` starts a new `orders-api-00017` instance at 23:31:10, and it connects and serves. The deploy is the cause; work through the [two hub checks](/learn/cloud-run-cloud-sql-connection-errors/#previous-revision).

## Where the checks mislead

The operation's span covers more than the outage. An Enterprise edition update can take 10 minutes while connectivity drops for seconds, so errors anywhere in the span fit maintenance, and errors that last the whole span need another explanation. During maintenance the database logs record messages from two different VMs, which can look like a second incident in the PostgreSQL log. [Maintenance impact](https://cloud.google.com/sql/docs/postgres/maintenance#maintenance-impact)

The end of the operation is not the end of the errors. Client settings such as connection type, query timeouts and connection pooling change the downtime an application observes. A pool that holds connections closed during the event can fail requests after the instance is back, especially on Cloud Run with request-based billing, where idle instances' CPU is throttled and pool maintenance threads pause. Read errors after `endTime` against the pool's settings before deciding they belong to the deploy. [Maintenance impact](https://cloud.google.com/sql/docs/postgres/maintenance#maintenance-impact) · [Connect from Cloud Run](https://cloud.google.com/sql/docs/postgres/connect-run)

Unlogged tables are empty after planned maintenance. If the new revision reads such a table and fails on missing rows, the symptom is not a connection error and does not appear in these checks. [Maintenance impact](https://cloud.google.com/sql/docs/postgres/maintenance#maintenance-impact)

Maintenance is not the only provider event in a deploy window. A failover or an automatic restart looks the same from the service; [the failover guide](/learn/cloud-sql-ha-failover-cloud-run-errors/) covers those, and [a provider incident during a rollout](/learn/cloud-provider-incident-during-rollout/) covers events outside the instance.

## Questions

### How long does Cloud SQL maintenance take down a PostgreSQL instance?

For Enterprise edition, the update takes about 5 to 10 minutes and connectivity is lost for less than 30 seconds on average. Enterprise Plus edition instances typically lose connectivity for less than one second. Busy instances and very large datasets can see longer interruptions.

### How do I see whether Cloud SQL maintenance happened at a given time?

Run `gcloud sql operations list --instance INSTANCE` and look for `MAINTENANCE` with `startTime` and `endTime` around the incident. Upcoming maintenance appears in `scheduledMaintenance` on the instance and in the `maintenance-events` log.

### Should I roll back a deploy that overlapped Cloud SQL maintenance?

Not on the overlap alone. If the errors stopped without a change, the rollback adds risk without fixing anything. If the new revision keeps failing after the operation ends while a fresh instance of the old one connects, the deploy is the cause.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Cloud Run cannot reach Cloud SQL: revision, identity or connection?](/learn/cloud-run-cloud-sql-connection-errors/)
    
    Broken dependencies The Proofline team November 23, 2026 10 min read
    
-   ### [Build a timeline of what happened to the Cloud SQL instance during an incident](/learn/cloud-sql-operations-during-incident/)
    
    Broken dependencies The Proofline team November 23, 2026 6 min read
