Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update files accumulating in /tmp #11566

Closed
habovh opened this issue Apr 19, 2021 · 12 comments
Closed

Update files accumulating in /tmp #11566

habovh opened this issue Apr 19, 2021 · 12 comments

Comments

@habovh
Copy link

habovh commented Apr 19, 2021

Environment

OS: Linux RN316 4.4.190.x86_64.1 #1 SMP Thu Oct 22 04:41:26 UTC 2020 x86_64 GNU/Linux

Description

Jackett does not delete files it stores in /tmp during the update process.
This eventually leads to update files accumulating on the disk, and in my case actually filling the disk up to 100% if no action is taken.

On low-storage devices this can become an issue, and NAS while having a lot of space on their data mount points often have tiny internal storage. I think it is safe to assume a lot of people using Jackett actually run in onto their NAS directly.

I'd like to keep Jackett up to date, so I'm not keen on disabling updates, but I think it would be a good thing to remove the previously downloaded update files after a successful update.

Screenshots

  • Listing /tmp folder:
    Screenshot 2021-04-19 at 15 21 27

  • Disk usage before removing /tmp/JackettUpdate* folders:
    Screenshot 2021-04-19 at 15 21 41

  • Disk usage after removing /tmp/JackettUpdate* folders:
    Screenshot 2021-04-19 at 15 21 54

@ilike2burnthing ilike2burnthing added Needs C# OS Linux / Mono / *nix PR Welcome! We would welcome a volunteer to prepare a PR to solve this problem! labels Apr 19, 2021
@ilike2burnthing
Copy link
Contributor

@NinjaLikesCheez / @XYZJR / @KaiSforza if any of you could have a look at implementing this it'd be a great help, thanks.

@garfield69
Copy link
Contributor

It might be a case of poor logic design. the UpdateService has a CleanupTempDir routine,

public void CleanupTempDir()
{
var tempDir = Path.GetTempPath();
if (!Directory.Exists(tempDir))
{
logger.Error($"Temp dir doesn't exist: {tempDir}");
return;
}
try
{
var d = new DirectoryInfo(tempDir);
foreach (var dir in d.GetDirectories("JackettUpdate-*"))
try
{
logger.Info("Deleting JackettUpdate temp files from " + dir.FullName);
dir.Delete(true);
}
catch (Exception e)
{
logger.Error($"Error while deleting temp files from: {dir.FullName}\n{e}");
}
}
catch (Exception e)
{
logger.Error($"Unexpected error while deleting temp files from: {tempDir}\n{e}");
}
}

which gets called daily from IUpdateService.cs

public interface IUpdateService
{
void StartUpdateChecker();
void CheckForUpdatesNow();
void CleanupTempDir();
void CheckUpdaterLock();
}

But its possible that the clean-up routine may only get called if CheckForUpdatesNow() does not have an update to perform, since if there is an update control is passed to the updater task which shuts the service down ...

Don't know that this is the case for sure, I'm not a C# dev and have not delved deeply into the Jackett code flow, but by pointing this out it may provide a volunteer a place to start investigating ;-)

@KaiSforza
Copy link
Contributor

@habovh Would be really useful to see the logs for this, if there are any.

@garfield69
Copy link
Contributor

On my win10 Jackett just now, I clicked on my dashboard's check for updates button, and after the notification popped up that Jacket was updated, I clicked on the view log button and seen

2021-04-20 19:06:52 | Info | Jackett startup finished in 32.271 s
2021-04-20 19:06:52 | Info | Deleting JackettUpdate temp files from C:\WINDOWS\TEMP\JackettUpdate-v0.17.908-637545423701964288
2021-04-20 19:06:52 | Info | Adding aggregate indexer ('all' indexer) ...

So I can confirm that on windows at least, the CleanupTempDir() routine is called and works OK.
Checking my C:\WINDOWS\TEMP\ folder there are no JackettUpdate-* folders about.

So the problem may be restricted to linux platforms... perhaps it is a permissions issue?

@habovh please check your log on the dashboard after an auto-update or a manual dashboard check-for-updates, and once the update is complete, view the log and check if you get the Deleting message as I do, and if there are any additional related error messages post them here. Thanks.

@garfield69
Copy link
Contributor

Tested this on my Win10 VirtualBox ubuntu 18.04 image, and the log shows

2021-04-20 20:08:05 | Info | Jackett startup finished in 3.179 s
2021-04-20 20:08:05 | Info | Deleting JackettUpdate temp files from /tmp/JackettUpdate-v0.17.908-637545460728672666
2021-04-20 20:08:05 | Info | Adding aggregate indexer ('all' indexer) ...

and once again there are no JackettUpdate-* folders on my /tmp/ folder

This is looking like a machine specific issue... is the OP's install of Jackett not using the standard builds or something?

@garfield69
Copy link
Contributor

Tested this on my win10 VirtualBox BigSur OSx image, and all looks good there too.
So that completes the main tri-facta of Jackett standard builds.

@garfield69 garfield69 added Needs Investigations More information needed and removed Core Needs C# PR Welcome! We would welcome a volunteer to prepare a PR to solve this problem! labels Apr 20, 2021
@habovh
Copy link
Author

habovh commented Apr 20, 2021

Thanks for the quick reaction guys!

I might have found the issue, and it does not seem to be related to Jackett itself, but more a docs issue.

I'm using systemd to manage Jackett and I used the provided systemd service from the wiki to get started. Back then, I was running Jackett with mono just like in the service from the wiki.

At some point I've updated the service to use jackett_launcher.sh as per this comment, but I did not change anything else than the ExecStart line.

I think that the Restart=always and RestartSec=2 were trying to restart Jackett at a time it should not. I changed for Restart=on-failure and removed the RestartSec & TimeoutStopSec entries.

It's looking promising, but I'll know for sure after an actual update is available (tomorrow) to confirm.

If it turns out this approach for working with systemd fixes my issue I'll recommend to update the wiki or might even do so myself if that's ok.

@garfield69
Copy link
Contributor

yes, please update the wiki, some of those pages are woefully out of date.
just remember that we still make available a mono flavour of jackett (despite our best efforts to drop support for it) because some niche platforms will not support the .net suite, so don't delete the mono references, just make it clear what works for which. Thanks.

@KaiSforza
Copy link
Contributor

I think that the Restart=always and RestartSec=2 were trying to restart Jackett at a time it should not. I changed for Restart=on-failure and removed the RestartSec & TimeoutStopSec entries.

I don't think this will cause an issue with the files staying there. RestartSec and TimeoutStopSec just handle things after the service has exited, and the update shouldn't cause the whole service to die.

It could be that the updater runs, and something on your system is not allowing it to continue, but the systemd service still restarts it and it technically updates (something happens here) but the changes made to the systemd service file won't make that any better.

@diegargon
Copy link

if it's good for anything, i never had that problem with Ubuntu
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal

@habovh
Copy link
Author

habovh commented Jun 8, 2021

I updated the wiki page as discussed.

@garfield69
Copy link
Contributor

@habovh Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants