IL-0483 Replicate · 2023-05-11database
Replicate's website and API returned slow responses and HTTP 500s for two hours as PostgreSQL connections ran out
Replicate's primary datastore is a PostgreSQL database, and starting a prediction depended on it directly. To keep predictions working during database maintenance or short outages, Replicate was adding caches and queues, and over 9 and 10 May it rolled out, behind feature flags, API service changes that wrote prediction state updates to the database asynchronously, outside the request handlers. A little after 14:00 UTC on 10 May the database primary was resized in just over a minute, and most users saw no disruption.
The asynchronous path removed about 100-150ms from creating a prediction, so two updates to the same prediction that used to arrive that far apart were now processed almost at the same time, and both tried to INSERT a row with the same unique prediction ID. Only one can succeed, and the queries contend for the unique index lock while the database decides, which makes all of them slower. The code fell back to updating the existing row when its INSERT failed, so users saw nothing at first, but slower INSERTs meant more parallel queries and more lock contention. A little after 05:00 UTC on 11 May normal traffic variation tipped this over, INSERT latency rose to tens of seconds, and from about 05:45 UTC the database connections were exhausted. After Crunchy Data helped rule out the database, Replicate switched all asynchronous prediction update features off with a feature flag at 07:31 UTC, and the database recovered within a few minutes.
- Severity
- –
- Scope
- replicate.com website and API: slow responses and HTTP 500 errors, predictions failing to run; webhook users saw relatively little disruption
- Users affected
- many customers
- Region
- –
- Time to detect
- 1m
- Time to resolve
- 2h
Symptoms
From 05:45 UTC on 11 May 2023, for about two hours, many Replicate customers got slow responses or HTTP 500 errors from the API and the replicate.com website and had trouble running predictions. Monitoring paged an engineer at 05:46 UTC, a minute after the database connection pool became fully saturated.
In the PostgreSQL database, INSERT latency jumped within a few minutes from about 1 millisecond to tens of seconds. More queries ran in parallel, each with its own database connection, until the maximum permitted number of connections was used up and new queries could not run at all. The website failed intermittently and was down more than it was up. Customers who received prediction updates by webhook instead of polling the API saw little disruption.
The first suspicion was the resize of the database primary the day before: perhaps the new primary had slower disks, or an auxiliary job on the new server was using disk I/O. The new asynchronous prediction update code looked an unlikely cause, because it had been enabled for more than 18 hours without visible problems. Replicate's database provider, Crunchy Data, responded within minutes and helped rule out problems with the database itself.
Symptom High error rateHigh latencyLock contention or deadlock
Root cause
Root cause Faulty deployment
- Trigger
- A little after 05:00 UTC on 11 May, normal variations in traffic pushed the stacking INSERT queries past their tipping point.
Detection
Monitoring detected the saturated database connection pool almost immediately and paged an engineer at 05:46 UTC.
Remediation
- Switched off all asynchronous prediction update features with a feature flag at 07:31 UTC, after which the database recovered
Action items
- Keep the asynchronous prediction update feature disabled and redesign it so it no longer sends stacked INSERTs
- Review lock contention and other database hotspots that could cause similar problems
- Publish detailed reports after major incidents
Lessons
The system ran in a degraded state that looked successful until it tipped into a full failure. The same asynchronous update work that triggered the outage also partly protected customers who used webhooks, and the stacked INSERTs came directly from a latency improvement: removing 100-150ms brought two updates of one prediction to the database almost together.
Sources
Related cases
IL-0356Every domain hosted on Railway returned HTTP 404 to new connections for five minutes because route lookups failedRailway · 2026same root cause · shared Database
IL-0136A deployment that cleared an internal service's caches at peak traffic sent 20 times the normal load to the Azure OpenAI metadata backend in Sweden Central, and health checks that depended on its database restarted instances in a loop for almost six hoursMicrosoft Azure · 2026same root cause · shared Database
IL-0570Dropping an unused MySQL table stalled queries on its busy parent table and crowdworks.jp was hard to reach for a minuteCrowdWorks · 2026same root cause · shared Database
IL-0510MIT Learn's RDS PostgreSQL ran out of storage after a release and learn.mit.edu returned 503s and 504s for hoursMIT Open Learning · 2026same root cause · shared Database
IL-0380A compaction change in InfluxDB Cloud us-east-1 dropped data from compacted files, and queries missed data for weeksInfluxData · 2026same root cause · shared Database
IL-0369Railway's backend API went down when a column migration waited on locks and replicas could not get database connectionsRailway · 2025same root cause · shared Database
IL-0547Buildkite annotation queries timed out and drove database CPU up across shards after a migration removed an indexBuildkite · 2025same root cause · shared Database
IL-0315Railway's backend API went down when an index build locked a billion-row Postgres table and used up every connectionRailway · 2025same root cause · shared Database
IL-0327After a blue/green upgrade of CircleCI's workflows database every query hit disk, and workflow starts lagged or failedCircleCI · 2025same root cause · shared Database
IL-0324Three MediaWiki deployments lost Memcached after a PHP 8.1 rollout and overloaded the External Storage database clusterWikimedia Foundation · 2025same root cause · shared Database
IL-0307Supabase's Postgres connection pooler Supavisor 2.0 dropped connections for about 80% of us-east-1 tenantsSupabase · 2025same root cause · shared Database
IL-0552CircleCI's archival database ran out of storage, slowing workflow and job starts and the display of workflows in the UICircleCI · 2025same root cause · shared Database
IL-0554A database migration used up Sentry US's Postgres connections, and the site and event ingestion were down for 22 minutesSentry · 2024same root cause · shared Database
IL-0571STORES reservation returned bursts of 504 errors when a smart-list query held a database process for over 20 minutesSTORES · 2024same root cause · shared Database
IL-0293Cloud Bigtable in us-central1 had higher latency and connection errors for about 32 hours from low-rate packet lossGoogle Cloud · 2023same root cause · shared Database
IL-0523TANF-app production deployments were blocked for two months when a search-index migration ran out of database disk spaceU.S. Department of Health and Human Services · 2023same root cause · shared Database
IL-0567Aurora MySQL behind Cookie Run: OvenBreak hit 100% CPU after a sales-ranking feature launch, and players could not playDevsisters · 2023same root cause · shared Database
IL-0371Half of new connections to Render Postgres databases with point-in-time recovery failed while their backup jobs ranRender · 2023same root cause · shared Database
IL-0524An index migration locked Open Collective's whole Transactions table and degraded the service for nearly an hourOpen Collective · 2023same root cause · shared Database
IL-0328A field type change in the database of CircleCI's job distribution service left all jobs stuck in "not running"CircleCI · 2021same root cause · shared Database
IL-0566Hot ranges after a Cookie Run: Kingdom guild update drove CockroachDB nodes to 100% CPU, forcing emergency maintenanceDevsisters · 2021same root cause · shared Database
IL-0391GoCardless API requests timed out for about 15 seconds while a Postgres migration waited for an AccessExclusive lockGoCardless · 2015same root cause · shared Database
Check your cluster for this
For AI tools and scripts
- This case as JSON: https://incidentlib-api.benchlet.com/cases/IL-0483
- The cases most like it: https://incidentlib-api.benchlet.com/cases/IL-0483/similar
- MCP server (Streamable HTTP, no key):
https://incidentlib-mcp.benchlet.com/mcp
The API needs no key. The MCP server offers search_incidents, get_incident, list_incidents, get_topic and vocab; both are explained on API and MCP.