Reputation: 6842
How to solve a Disk full error in Docker Volume using a Postgresql database.
I'm not sure if the issue is with docker, docker volumes or Postgres configuration.
Environment
Docker on MAC - Postgresql
The following error happens while running a Rails application.
PG::DiskFull: ERROR: could not write to file "base/pgsql_tmp/pgsql_tmp125.6.sharedfileset/i35of64.p0.0": No space left on device
I'm also having these types of issues when importing database dump
ERROR: could not extend file "base/1051062/1259": No space left on device
HINT: Check free disk space.
STATEMENT: CREATE INDEX index_some_table_key ON public.some_table USING btree (xyz_id, abc_key) WHERE ((NOT deleted) AND (abc_key IS NOT NULL));
Container shell disk size
docker exec -it pg13 bash
root@51fe1c96f701:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 59G 56G 26M 100% /
tmpfs 64M 0 64M 0% /dev
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
shm 64M 1.3M 63M 2% /dev/shm
/dev/vda1 59G 56G 26M 100% /etc/hosts
tmpfs 2.0G 0 2.0G 0% /proc/acpi
tmpfs 2.0G 0 2.0G 0% /sys/firmware
I have been gradually working through different ways of using pg_restore
# many indexes in the database fail to create
pg_restore -h 127.0.0.1 -U postgres -d "mydb" "mydump.dump"
# when running data only, the restore works
pg_restore --section=pre-data --section=data -h 127.0.0.1 -U postgres -d "mydb" "mydump.dump"
# when running for specific TOCs, I sometimes have success and sometimes have out of disk space errors
pg_restore -v -L x.txt -h 127.0.0.1 -U postgres -d "printspeak_development" "salescrm.dump"
# contents of x.txt
;5971; 1259 31041251 INDEX public index_account_history_data_tenant_source_account_platform_id salescrm
;6138; 1259 2574937 INDEX public index_action_logs_on_action salescrm
Database that was restored
I have a created a data base and restored a dump from production.
.dump file was 8GB in size and the imported database is 29GB in size
SELECT pg_size_pretty( pg_database_size('mydb_development') );
pg_size_pretty
----------------
29 GB
Docker Compose
volumes:
pgdata:
services:
pg13:
container_name: "pg13"
image: "postgres:latest"
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "xyz"
# Increase the Write Ahead Log size because of warnings.
command: "postgres -c max_wal_size=2GB"
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
What made this issue difficult to figure out (misled me).
I had enough disk space in the Docker for the Database + Data + Many of the indexes.
But not all the indexes and there was also some randomness to the create indexes, sometimes they worked, sometimes they didn't.
Upvotes: 3
Views: 7735
Reputation: 6842
The issue was with the amount of disk space being allocated by Docker and ended up being a simple fix in the Docker GUI.
Upvotes: 20