qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
27.96k stars 3.95k forks source link

Qbittorrent-nox rechecks/rehashes all torrents when restarted #2901

Closed psbj closed 9 years ago

psbj commented 9 years ago

I'm using qbittorrent-nox with the webui on a headless installation of debian.

I used the build through apt-get previously (3.1.10) and today I tried out 3.2.0beta and the issue is still there. This was also an issue when I was running qbittorrent-nox on my raspberry pi (raspbian).

Whether it's stopped by a loss of power, intended shutdown, daemon stopping, or "exit qbittorrent" in the webui menu, all torrents are forced to recheck when it's started again.

This is a huge problem for people with a lot or very large torrents (or both).

chrishirst commented 9 years ago

What version of libtorrent is it built against? See #2750 (and #2853)

psbj commented 9 years ago

Currently it's libtorrent 1.0.4, but previously it was libtorrent 0.16.18.

I tried compiling earlier versions of libtorrent but it says it's missing boost_system or something, even though it's not. 1.0.4 has non issues compiling.

chrishirst commented 9 years ago

Okay I would suggest that this is starting to point to a libtorrent problem in v1.03 and above.

psbj commented 9 years ago

I had this problem with libtorrent 0.16.18 as well.

sledgehammer999 commented 9 years ago

Can you check the contents of "BT_backup" folder? When you close qbt, are .fastresume files created in there? Can you alsos check the permissions of that folder and its contents? You'll find this folder in $HOME/.local/share/data/qBittorrent/

psbj commented 9 years ago

I just checked and there are .torrent and .fastresume files there. I started qbittorrent-nox and it resumed the torrents without problem.

This is weird, because I tested last night and it was rechecking all the torrents once I restarted the service.

Not sure what has changed but it appears to be working fine now. Strange.

sledgehammer999 commented 9 years ago

Can you share the script that starts/restarts/stops the qbt service?

psbj commented 9 years ago

It's the one in the wiki: https://github.com/qbittorrent/qBittorrent/wiki/Running-qBittorrent-without-X-server#how-to-run-qbittorrent-nox-on-startup

sledgehammer999 commented 9 years ago

Your problem may arise during system shutdown if you have many torrents in qbt. Note: I am not very good with bash and linux scripting in general. Look at the do_stop() function of the script you linked.

start-stop-daemon -c $USER --quiet --stop --exec $DAEMON

The above sends a SIGTERM signal to qbt which is ok. When qbt receives this, it starts shutting down by first trying to save the fastresume files. However this can take several seconds if you have many torrents. In fact even if you only 2-3 it may take at least 3 seconds to close. So the sleep 2 may not be enough. Only 2 seconds. So during system shutdown, the service is supposedly stopped after ~2 when in fact qbt may still be running in the background. And since the script reported that the service is stopped, the OS shutdown continues and at some point it kills qbt.

The above is just a speculation. I may be totally wrong. IMO, after the sleep there should a check of the running processes. If qbt is still running is should sleep again for 2 secs. So putting the sleep in a while loop that checks for running qbt should suffice. (Don't expect any bash code from me though :P )

psbj commented 9 years ago

Considering I have over 500 torrents I think it's safe to say that's the problem. Thanks for the help!

sledgehammer999 commented 9 years ago

The man page for start-stop-daemon: http://manpages.ubuntu.com/manpages/lucid/en/man8/start-stop-daemon.8.html

You should add --retry 120 to the above command. It should recheck if qbt has finished before returning. And it should recheck continously for 2minutes. After 2 minutes it will error out.