PostgreSQL error: could not extend file no space left on device

Viewed 3738

I'm running a query that duplicates a very large table (92 million rows) on PostgreSQL. After a 3 iterations I got this error message:

Screenshot of the error message

The query was:

CREATE TABLE table_name
AS SELECT * FROM big_table

The issue isn't due to lack of space in the database cluster: at 0.3% of max possible storage at the time of running the query, table size is about 0.01% of max storage including all replicas. I also checked temporary files and it's not that.

1 Answers

You are definitely running out of file system resources.

Make sure you got the size right:

SELECT pg_table_size('big_table');

Don't forget that the files backing the new table are deleted after the error, so it is no surprise that you have lots of free space after the statement has failed.

One possibility is that you are not running out of disk space, but of free i-nodes. How to examine the free resources differs from file system to file system; for ext4 on Linux it would be

sudo dumpe2fs -h /dev/... | grep Free
Related