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

Does not always remove lock file when stopped #57

Open
ghost opened this issue Dec 17, 2022 · 6 comments
Open

Does not always remove lock file when stopped #57

ghost opened this issue Dec 17, 2022 · 6 comments

Comments

@ghost
Copy link

ghost commented Dec 17, 2022

I frequently have an issue where rtorrent does not remove its lock file when stopping (running in Docker), meaning that next time it starts I get the "could not lock session directory" error and have to manually remove the lock file and restart the container.

@m3Lith
Copy link

m3Lith commented Dec 27, 2022

I've just encountered this same issue a couple of days ago too, for the first time.

@animaldaydream
Copy link

animaldaydream commented Jan 31, 2023

The lock file contains a hostname, which apparently does not always persist.

podman kill rtorrent (rtorrent is the container's local name) kills the container and leaves behind the lock, which contains the hostname of the container. If you remove the lock file and set a hostname when creating the container, the lock file will have the new hostname and rtorrent will manage it properly.

Please try to test this theory and report back! This had been bugging me for a while.

@kannibalox
Copy link
Contributor

Processes that are hard killed (by podman kill or otherwise) have no chance to clean up after themselves, so it's generally not advisable unless the process is actually stuck. By default, both podman's and docker's stop commands will give containers 10 seconds to gracefully exit before hard killing it. There is no way for this to be fixed from rTorrent's side, it must be allowed to gracefully exit in order to clean up the lock file.

@animaldaydream
Copy link

Well of course, I know what killing means in Linux.

Anyways, in various situations Podman will forcefully terminate the container after ten seconds instead of waiting for it to stop gracefully. But I just did it this way to artificially trigger the problem.

It seems rtorrent can manage the lockfile just fine, but the hostname must be static. If not specified, on docker or podman run commands it seems it generates one on the spot. Makes sense, in hindsight. But rtorrent then thinks it's potentially managing something else's lock file and refuses to operate.

Setting a hostname manually worked for me, so I'm mostly asking to see if it was a fluke.

@kannibalox
Copy link
Contributor

Well of course, I know what killing means in Linux.

I wasn't responding to you specifically, just trying to provide more context on why this also might happen from a regular docker stop, and why it's not an rtorrent bug. My apologies if it came off otherwise.

It seems rtorrent can manage the lockfile just fine, but the hostname must be static. If not specified, on docker or podman run commands it seems it generates one on the spot. Makes sense, in hindsight. But rtorrent then thinks it's potentially managing something else's lock file and refuses to operate.

Setting a hostname manually worked for me, so I'm mostly asking to see if it was a fluke.

The information rtorrent uses to check if the lockfile belongs to someone else is the hostname and PID (the lock file is in plaintext, you can just cat it to see the data), so if you give your container a static hostname and rtorrent runs as PID 1 (or at least something consistent), rtorrent will consider the lock file stale and just adopt it.

@animaldaydream
Copy link

so if you give your container a static hostname and rtorrent runs as PID 1 (or at least something consistent

that's nice, because the file always says +1 at the end. maybe it checks if the PID is an rtorrent process or something.

but then again it also probably has to do with how absurdly minimal the container is. you can't even run sh on it. perhaps it is indeed always PID 1

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

No branches or pull requests

3 participants