Nov 23, 20266 min read

RDS Storage Full: Storage Autoscaling and Recovery

What happens when an RDS for PostgreSQL instance runs out of storage, how to get it writable again, what usually fills the disk, and how to set up storage autoscaling and alarms so it does not happen twice.

Illustration for RDS Storage Full: Storage Autoscaling and Recovery

An RDS for PostgreSQL instance that runs out of disk does not slow down gracefully, it switches to the storage-full status and every write fails, which usually means checkout, signups and background jobs all break at once.

Getting it writable again takes one modification, and making sure it does not happen again means finding what filled the disk and letting storage autoscaling handle normal growth.

At a glance

CauseHow it shows upFix
Normal data growthSteady decline in FreeStorageSpaceStorage autoscaling with a sensible maximum
Inactive replication slotWAL keeps growing, restart_lsn far behindDrop the slot or reconnect its consumer
Large temporary filesSudden drops during reports or migrationstemp_file_limit, fix the query
Postgres log filesGrowth after enabling verbose loggingLower rds.log_retention_period or log less
Table and index bloatSize grows faster than row countAutovacuum tuning, pg_repack
Old data nobody readsEvent and audit tables dominateRetention job or partitioning

Get the instance writable again

The DB instance status reference calls storage-full a critical status and says to fix it by modifying the instance to add storage. You must increase allocated storage by at least 10 percent. Apply the change immediately rather than in the maintenance window:

aws rds modify-db-instance \ --db-instance-identifier orders-prod \ --allocated-storage 150 \ --max-allocated-storage 400 \ --apply-immediately

--max-allocated-storage turns on storage autoscaling at the same time. The instance moves through modifying and storage-optimization, and writes generally work again once the new size is in place, but the optimization phase can take hours on large volumes, and the next storage change has to wait six hours or until storage optimization finishes.

Find what filled the disk

Replication slots. A logical replication slot whose consumer stopped, from a CDC tool or an abandoned replica, makes Postgres keep every WAL segment since the slot's restart_lsn. The replication slots documentation warns that slots retain WAL until the consumer catches up, without limit unless max_slot_wal_keep_size is set:

SELECT slot_name, slot_type, active, pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS retained_wal FROM pg_replication_slots ORDER BY pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) DESC;

An inactive slot holding tens of gigabytes is the usual suspect when storage vanishes on an instance whose tables did not grow. Drop it with SELECT pg_drop_replication_slot('slot_name') if nothing needs it.

Temporary files. Sorts and hashes that exceed work_mem spill to disk, and one bad report query can write more than the free space. pg_stat_database.temp_bytes shows the cumulative amount per database, and temp_file_limit, described in the resource consumption settings, caps what a single session may write.

Tables, indexes and bloat. This lists the largest tables with their dead tuples:

SELECT relid::regclass AS table_name, pg_size_pretty(pg_total_relation_size(relid)) AS total, pg_size_pretty(pg_indexes_size(relid)) AS indexes, n_dead_tup FROM pg_stat_user_tables ORDER BY pg_total_relation_size(relid) DESC LIMIT 10;

Logs. Postgres log files live on the same volume, so log_statement = 'all' or very low log_min_duration_statement values on a busy instance can fill it, and rds.log_retention_period controls how long they are kept.

Set up storage autoscaling properly

The storage autoscaling documentation lists when RDS grows the volume: free space at or below 10 percent of allocated storage for at least five minutes, the previous storage optimization finished, and fewer than four storage modifications in the past 24 hours. Each step adds the largest of 10 GiB, 10 percent of current storage, or the growth predicted for the next seven hours from the last hour of FreeStorageSpace.

A runaway process that fills the disk faster than the optimization cycle can still hit storage-full, so autoscaling is not a substitute for finding the cause, and since storage cannot shrink, a maximum threshold set far above the storage you need turns a leak into a permanent cost. Set the threshold to what you are prepared to pay for, and add a CloudWatch alarm on FreeStorageSpace so a person looks before the threshold is reached.

Best fit: autoscaling with a deliberate maximum, an alarm on free space, and a retention policy for data that only grows.

Retention and storage in Encore

Encore

Encore brings infrastructure from code: a service declares its Postgres database in the application, and Encore provisions it on RDS in your AWS account. According to the AWS infrastructure docs, a new RDS instance starts with 10 GiB of gp2 storage with autoscaling up to 20 GiB, and the storage settings can be changed per environment in the Platform Dashboard, so raising the ceiling for production is a configuration change rather than a code change. The infrastructure configuration docs also note that changes made directly in the AWS console are detected and not overwritten.

For data that only grows, a retention job belongs next to the table it cleans. This events service deletes rows older than 90 days in batches of 5,000, so each statement holds locks briefly and autovacuum can reuse the space:

Get started
brew install encoredev/tap/encore &&
encore app create
Copy

Run in your terminal to get started locally.

// events/retention.go package events import ( "context" "encore.dev/cron" "encore.dev/rlog" "encore.dev/storage/sqldb" ) // migrations/1_create_events.up.sql: // CREATE TABLE events (id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, // kind text NOT NULL, payload jsonb NOT NULL, // created_at timestamptz NOT NULL DEFAULT now()); // CREATE INDEX events_created_at_idx ON events (created_at); var db = sqldb.NewDatabase("events", sqldb.DatabaseConfig{Migrations: "./migrations"}) var _ = cron.NewJob("events-retention", cron.JobConfig{ Title: "Delete events older than 90 days", Schedule: "15 3 * * *", Endpoint: PruneOldEvents, }) type PruneResult struct { Deleted int64 `json:"deleted"` } //encore:api private func PruneOldEvents(ctx context.Context) (*PruneResult, error) { var total int64 for { res, err := db.Exec(ctx, ` DELETE FROM events WHERE id IN ( SELECT id FROM events WHERE created_at < now() - interval '90 days' ORDER BY created_at LIMIT 5000 ) `) if err != nil { return nil, err } total += res.RowsAffected() if res.RowsAffected() < 5000 || ctx.Err() != nil { break } } rlog.Info("pruned events", "deleted", total) return &PruneResult{Deleted: total}, nil }

The cron jobs docs describe how scheduling works: cron jobs are managed by the Encore platform and run on the schedule in deployed environments, not locally or in preview environments, so during development a test inserts a few old rows into the local database encore run starts and calls PruneOldEvents directly. The databases docs cover the migration with the created_at index the batch query needs.

An AI coding agent adding a new event or audit table can add its retention job in the same change, with the schedule and the query next to the table, which keeps "we should clean that up at some point" from becoming the next storage-full incident.

Best fit: services with append-heavy tables that want growth handled by configuration and cleanup handled by code next to the data.

Frequently asked questions

What does storage-full mean on RDS?

storage-full is an RDS instance status that means the instance has used all of its allocated storage. Postgres cannot write new data, so inserts and updates fail until you increase allocated storage by at least 10 percent.

How does RDS storage autoscaling work?

With autoscaling enabled, RDS adds storage when free space is at or below 10 percent of allocated storage for at least five minutes. It grows by the largest of 10 GiB, 10 percent of current storage or the predicted growth for the next seven hours, up to the maximum storage threshold you set.

Can I reduce RDS storage after it grows?

No. RDS cannot shrink allocated storage on an existing instance. To get a smaller volume you restore or migrate the data into a new instance with less storage, so fix the cause of the growth before raising the limit far beyond what you need.

How do I keep an Encore app's database from filling up?

Raise the storage settings for the environment's database where needed and add an Encore cron job that deletes old rows in small batches. The cron job runs on the schedule in deployed environments, not locally or in preview environments, so test it by calling its endpoint from a test against the local database.

Deploy to your cloud on AWS and Google Cloud
without managing infrastructure

Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders