lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

pictrs orphaned temp files

Open pixlguru opened this issue 3 years ago • 14 comments

Issue Summary

in pictrs containers' /tmp/ directory orphaned magick-* temporary files are accumulating, (like 10GB in 2 weeks)

Technical details

errors in pictrs logs:

Sep 20 17:47:28.407  INFO actix_server::builder: SIGTERM received, stopping    
Sep 20 17:47:28.407  INFO actix_server::worker: Shutting down worker, 0 connections    
Sep 20 17:47:28.408  INFO actix_server::worker: Shutting down worker, 0 connections    
Sep 20 17:48:15.259 ERROR sled::config: cache capacity is limited to the cgroup memory limit: 209715200 bytes    
Sep 20 17:48:15.340 ERROR sled::config: cache capacity is limited to the cgroup memory limit: 209715200 bytes    
Sep 20 17:48:15.356  INFO actix_server::builder: Starting 2 workers    
Sep 20 17:48:15.356  INFO actix_server::builder: Starting "actix-web-service-0.0.0.0:8080" service on 0.0.0.0:8080```

pixlguru avatar Sep 20 '21 20:09 pixlguru

cc @asonix

dessalines avatar Sep 21 '21 00:09 dessalines

The logs presented are not related to the problem, and are actually not important. Sled doesn't like when you constrain it's RAM but it won't cause issues.

Cleaning up ImageMagick's tmp files happens automatically in pictrs 0.3, but I'm not sure how I'd get it working in 0.2. I can start looking into this, though

asonix avatar Sep 21 '21 01:09 asonix

Its pry not necessary, I'd rather focus on moving to 0.3 when you're ready for that.

dessalines avatar Sep 21 '21 01:09 dessalines

ok, as a workaround i just run scheduled docker exec -it lemmy_pictrs_1 /bin/bash -c "rm /tmp/magick-*"

pixlguru avatar Sep 24 '21 09:09 pixlguru

In that case I'll close this, but of course this'll be searchable.

dessalines avatar Sep 24 '21 14:09 dessalines

The issue still persists, it recently crashed the server

pixlguru avatar May 23 '23 18:05 pixlguru

Which pictrs version are you using? And how did temp files crash your server? Do you have a log?

Nutomic avatar May 23 '23 20:05 Nutomic

I'm using the version the ansible setup provides. The server crashed cause it ran out of disk space, corrupting the database. It was caused by leftover pictrs magick-* temporary files inside it 's docker containers /tmp folder

pixlguru avatar May 23 '23 20:05 pixlguru

After digging some more into it, I found these entries in syslog syslog

pixlguru avatar Jun 03 '23 06:06 pixlguru

I'll try increasing pictrs mem_limit and see how this works out

pixlguru avatar Jun 03 '23 07:06 pixlguru

that does point to an issue in pict-rs for cleaning up tmp files when imagemagick, ffmpeg, or exiftool get killed. I'll look into this for 0.4 stable

asonix avatar Jun 04 '23 00:06 asonix

oh, just re-read your command for cleaning the orphaned files. those magick- files are left behind by imagemagick, and i'm hesitant to add logic to pict-rs to clean them in case they're still in use. I think increasing the container's memory limit is probably the correct solution here

asonix avatar Jun 04 '23 13:06 asonix

alternatively, you could play with the values in imagemagick's policy xml file. This is the default one pict-rs ships with: https://git.asonix.dog/asonix/pict-rs/src/branch/main/docker/object-storage/root/usr/lib/ImageMagick-7.1.0/config-Q16HDRI/policy.xml

it needs to be mounted to /usr/lib/ImageMagick-7.1.0/config-Q16HDRI/policy.xml inside the container

asonix avatar Jun 04 '23 13:06 asonix

Seems the files are left behind if pictrs crashes due to OOM. Increasing the containers mem_limit resolved the issue

pixlguru avatar Jun 05 '23 07:06 pixlguru