Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql | No space left on device

I am getting space issue while running a batch process on PostgreSQL database.

However, df -h command shows that machine has enough space

enter image description here

below is the exact error

org.springframework.dao.DataAccessResourceFailureException: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; ERROR: could not extend file "base/16388/16452": No space left on device
  Hint: Check free disk space.

What is causing this issue?

EDIT

postgres data directory is /var/opt/rh/rh-postgresql96/lib/pgsql/data

df -h /var/opt/rh/rh-postgresql96/lib/pgsql/data
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda2      100G   63G   38G  63% /
like image 322
YogeshR Avatar asked Jun 13 '18 09:06

YogeshR


People also ask

How do I fix No space left on device?

Fix 1: Restart Processes Using Deleted Files The most probable cause of the “No space left on device” error is a process still using a deleted file. Thankfully, fixing this error is easy. You just need to restart the process to free up the reserved storage.

What is no space left on device?

No space left on device error often means you are over quota in the directory you're trying to create or move files to. 1. If you are trying to move a file from another location, change the group ownership of the file before moving it or use the copy command instead.

How do I fix Errno 28 no space left?

Your local folder does not have enough space available for the operation. In your environment, update the 'TEMP', 'TMPDIR' or 'TMP' environment variable to a location with additional free space. Validate the updated location: Windows - command-prompt 'set'


1 Answers

Most likely there are some queries that create large temporary files which fill up your hard disk temporarily. These files will be deleted as soon as the query is done (or has failed), so the file system has enough free space when you look.

Set log_temp_files = 10240 in postgresql.conf (and reload) to log all temporary files exceeding 10 MB, then you can check the log file to see if this is indeed the reason.

Try to identify the bad queries and fix them.

If temporary files are not the problem, maybe temporary tables are. They are dropped automatically when the database session ends. Does your application use temporary tables?

Another possibility might be files created by something else than the database.

like image 105
Laurenz Albe Avatar answered Oct 01 '22 13:10

Laurenz Albe