Closed Rik44444 closed 4 years ago
Thanks for the report! Does this issue still persist?
jep still happening. I'll be happy to upload an error log, as soon as you can help me figure out how to make one :P
This has started to happen to me recently too. I was on 7.4.4 and upgraded to 7.5.0-rc5, still same behavior. It stays at 0 Kb/s for a long time, hours even, then maybe after a while it finally resumes downloading, pretty fast. Sometimes closing the program and opening it up again solves it, at least momentarily.
I just upgraded my Ubuntu MATE from 19.10 to 20.04. I think it coincided with the moment in which the problem started to happen, but cannot confirm it at 100%.
Also, I remember to have had this same problem last year, but then stopped. I don't remember how or why it stopped. Possibly due to updating my Ubuntu or Tribler. I was on Ubuntu MATE 18.04 back then, with whichever was Tribler's latest version.
interesting.. Seems dupe of #5307
Seems Windows 10, Mate, and Mac users have seen this performance bug. We should try to catch this in our app stress tester infrastructure.
@aaguilarjimenez , @Rik44444 , please indicate does it happen only with anonymous downloads or with non-anonymous too?
@aaguilarjimenez , @Rik44444 , please indicate does it happen only with anonymous downloads or with non-anonymous too?
sorry i've always only tried anonymous. I'll try non-anonymous next time
@aaguilarjimenez , @Rik44444 , please indicate does it happen only with anonymous downloads or with non-anonymous too?
Same as Rik44444, only ever tried with anon downloads (1 hop). I'll try to download something non-anon when my downloads are frozen and come back at you with the result...
We are trying to capture this nasty bug on our testing machines so hopefully we will have a solution for this issue soon.
I have no problems with 0-hop downloads, but I am also getting regular speed drops with anonymity enabled. While this is expected to some extent, since circuits only have a limited lifetime, I often see circuits getting destroyed well before their traffic limits are met. The cause seems to be that exit nodes are destroying the circuits intentionally, because my balance is too low.
It could be that there are not enough slots and users are kicked out (and their circuits are thus destroyed). I'm not sure how often this problem occurs specifically but a user is likely to maintain multiple circuits with distinct exit nodes.
Can we return the reason why the circuit got destroyed to the user somehow? If we get multiple of circuit destructions within a short time, we can display a warning to the user (something like: the performance of anonymous downloads might be affected by a low token balance). This will not solve the root problem since users should be able to increase their balance again (which can currently only be done by relaying traffic), but it would inform the user at least.
Can we return the reason why the circuit got destroyed to the user somehow?
There is actually a backwards-compatible reason
in the wire format for this. We should be able to extend it and deliver it to the user using the Tribler notifier in the TriblerTunnel subclass. Reference:
From what I can tell by looking at the code, the most likely reason why an exit would destroy a circuit after creation is due to a low balance. Other reasons are when the exit is unloading the TunnelCommunity
or when we've sent more than 50 packets to the outside world without a response. I guess the latter is also a possibility. Of course, it's best not to guess, so using reason
field sound like a good idea. Currently, the reason always seems to be 0
.
I realize there are almost always multiple circuits available, but switching from one circuit to the next is still going to result in a dip in speed. From what I've experienced the speed almost always goes back to 0. Balancing the load over the existing circuits seems difficult since most of the speed is often coming from a few connections.
A user reported on our forum:
I was using 7.4.4 for win10. I’ve experienced a weird error these days. At first, all of my downloads couldn’t connect any peers at all. I tried to change settings and all of that. But it didn’t work. So I tried reinstalling it. I didn’t have the luck. So I tried 7.5.0-rc5. Now it seems that the downloads found their peers back, even though they don’t really connect with them nor download anything. But the weirdest thing happened. When I put anything to “zero hoops,” it cannot find a single seed or peer at all. Usually, without anonymity, I could download things much faster. But now anonymity mode doesn’t download things, while non-anonymity mode gives me literally nothing, not even a peer.
Currently, download got much smoother. But still, I have trouble with seeding. Once a file finishes downloading, all the seeds and peers disappear. So Tribler doesn’t seed at all after finishing it. (Of course, my setting’s at unlimited seeding.)
About the non-anonymous download, I just added a torrent, but it doesn’t connect to anything. Funny thing is when I change it into anonymous download, it connects seeds/peers and starts the download.
This is very new. Before, I used non-anonymous download because I didn’t like the speed of anonymous mode. But now the non-anonymous mode doesn’t do anything.
@ichorid We're only seeding through e2e circuits, meaning that you can only upload to other Tribler users. Chances are that there are simply no other Tribler users downloading the torrent. So, I'm not surprised about the problems with seeding.
I've never seen a download that only works if hops>0. Not sure what's happening here.
Bug triggered again, now during "disk checking"!
Tribler 7.4.4 did not have this, 7.5rc5 introduces new behavior that triggers this. Not a Mac only issue, also reported by others on Linux Mate and @Rik44444 on Windows 10.
This is the last big issue we need to resolve before we can finally declare things stable and release 7.5 of Tribler. Tribler RC5 stuck on disk checking with 3 concurrent other swarms active (but not actively downloading, no IO at all, just dead swarms, stuck for weeks at same download percentage). This was not simply disk checking, I deleted a file underneath Tribler. Then starting a disk check to ensure it is in sync with 0% and 100% downloaded files. Worked smoothly before on RC5, but now it triggered some sort of deadlock:
https://github.com/arvidn/libtorrent/issues/4661 looks like our case
"set_alert_notify
may deadlock when called more than once"
we refactored a lot of Libtorrent-related stuff during 7.5. Another detail is that we refactored Libtorrent wrapper after moving to asyncio
. That explains why we only started to experience the problem later.
@egbertbouman , could you please remember if you changed stuff related to alerts/thread during the refactoring?
@ichorid The libtorrent wrapper does everything on the same thread. If it's a threading issue it's more likely because we're calling it from somewhere we shouldn't (i.e., not the asyncio
thread).
The basics of how we get the alerts from libtorrent and how we process them are all the same.
BTW, note that we are not actually using set_alert_notify
, instead we use pop_alerts
to get the alerts from libtorrent.
Well, that was a good attempt... Not our case.
At least we now know not to use set_alert_notify
.
@synctext did you use external media to store the files that got stuck? Something like a USB flash drive or a slow external HDD?
ruling out set_alert_notify()
, I think there are two separate symptoms left:
Case 1: This could have lots of different causes. The disk throughput being saturated could definitely be one of them, but also dropping peers (for whatever reason). I think a long term approach to debugging issues like this would be to have a feature where libtorrent stats counters can be enabled and recorded into a log file (i.e. [post_session_stats](https://libtorrent.org/reference-Session.html#post_session_stats())). Those counters could be saved in a binary format to save space, but the default alert::message()
function will print them in text format, which can be parsed by tools/parse_session_stats.py
(in the libtorrent repo). It would record the size of the disk write queue for instance, as well as the number of bytes being written to disk.
Case 2: I'm pretty confident that this symptom always must be caused by one or more threads being "stuck" in system calls that cannot be interrupted, or in modes where they cannot be interrupted. I would expect one such case would be a write()
call to disk, on a system that are under heavy memory pressure and cannot easily allocate another dirty page, and maybe has to do a lot of paging activity to find one. Normally you would expect just the disk thread to get stuck though, but there may be non-obvious dependencies that cause other threads to wait for the disk somehow. Or under such condition of the system any paging activity might cause all threads to get stuck in a page fault.
I think the most reasonable way to resolve issues like this would be to sample the process when this happens, which requires debug symbols, or at least some extent of debug symbols to resolve some of the function names. This is problematic for end-users to do, since tools for this aren't easy to come by (Mac OS and BSD has sample
and I think windows task manager can sample stack traces from the context menu).
@arvidn , thank you very much for the clarification. :clap:
So, I tried to download some torrents on a slow USB stick (non-anonymous). There were 5 popular, highly seeded torrents. The first two I added started immediately, but the speed was very low, like 0.5-15 kb/s. But the remaining 3 torrents were stuck in "Checking" for about 5 minutes. After that, they started too, with the same low speed. This is totally reproducible. I don't know what "Checking" status means in this case. After a couple more minutes the speed for every download will jump up to hundreds of kb/s and for some to even 2 mb/s. Then after a minute, it will again drop to a bytes per second.
@arvidn, is it normal?
@Rik44444 , @aaguilarjimenez , could you please indicate what kind of media you used while experiencing the bug? Did you download directly to an external USB stick or something like that?
I'm not sure what "checking" means either. libtorrent has two checking modes. Checking resume data and checking files.
Since it sounds like you didn't have these files already, it probably means checking resume data. That name is a bit misleading since it does things even when you don't have resume data.
It will stat()
every file in the torrent at the specified save directory, to see if any file is there. It will also do various kinds of sanity checking of resume data, if it was provided.
If you have a torrent with a lot of files to be stat()
ed on a slow drive, I suppose that could take a long time. 5 minutes sounds very long though. It normally takes a fraction of a second. However, if any files were found. it would transition into file-checking mode, where it actually has to read all data from the files and check their hashes.
Whether it's normal or not, I don't know. It probably depends on what the bottleneck is.
yes, relatively slow external USB. plus: this was a fault when data file checking..
@synctext , we've seen exactly the same problem last year with your laptop using a slow external USB flash drive. I was able to reproduce it today by using a slow external drive. Checking was basically stuck. Also, as pointed out by @arvidn, "Checking" at 0% means libtorrent is trying to stat()
the files at the disk in question. If the disk is very busy with i/o, it will probably block.
Was it a USB Flash drive or an HDD? what model (controller, etc.)? what filesystem does it use? Did you try to use it simultaneously with some other process accessing it, e.g. watching Tribler VLC streaming from it?
@synctext , also, could it be that your GigaChannel database was on the same USB drive? Was Tribler processing/downloading some channels at that moment (especially, big ones)?
with 7.4.4 this checking never gave issues, plus no 0kbps issues with healthy big swarms. no idea on Channel parsing activity. This should be inside Tribler RC6 debug panel then please, channel inserts in last seconds.
btw channel.db is inside .Tribler dir on fast SSD, not on slower USB used for bulk swarm storage.
Reproduced, coool!
Reliably reproduced on Windows 10 with both 7.4.4 and 7.5. Note that DHT checking works!
Downloads are stuck for the first few minutes after adding them, then resume.
I suspect this is not one, but several problems resulting in slightly different, albeit very similar effects. The first one has something to do with DHT - peers connecting. The second one is about libtorrent getting stuck due to slow disk access.
Is the USB stick formatted with FAT by any chance? i.e. not supporting sparse files?
yes! Dos format, Linux and Mac compatible. But again, it used to work fine.
is the difference libtorrent-1.1.x and libtorrent-1.2.x?
I ran a test downloading a large file into a usb stick on linux using client_test
(a pretty thin wrapper around libtorrent).
Here area few observations:
I can reproduce the stall (where the debugger is even stuck stopping the process, supporting the thesis that it's blocked in a long-running system call).
While running the download, I don't see any stalls, just when I stop the download. My interpretation of this is that Linux fills-in the non-sparse file lazily. i.e. writing the last byte in a large file doesn't itself block while filling the file with zeroes, but it's filled in when the file is closed. This has also been my experience on MacOS on HFS+.
when disk is busy allocating the file, it's very easy to also lock up the foreground thread by accessing the disk, even for a very small file, can block. in client_test
the foreground thread saves resume data files (which are very small), but still causes the user interface to lock up.
In the past, libtorrent used to have a dedicated thread just to close files (here), specifically for this reason. It doesn't anymore though, and maybe it was a mistake to remove that. Although, this was removed such time long ago that I find it unlikely this is what's affecting you.
A few ways I can think of to mitigate this would be to:
increase the file pool size. This would (presumably) cause files to be closed less often. And if a non-sparse file is closed after it has been fully "filled-in", it's cheap.
increase the number of disk I/O threads, which would allow more threads to be blocked in closing files, while still making progress in other threads.
It seems this ticket is mostly about windows, and I don't feel confident assuming windows has the same behavior as I've experienced on Linux and Mac OS, but this might at least help with ideas of what's going on.
@arvidn , thank you very much for your insights! This thread now seems to be about multiple issues that manifest differently on different platforms, but any of them results in 0kb/s downloads.
Latest 7.5-rc5, Win10, Libtorrent version 1.2.1. Run Tribler, add 3 highly popular torrents by infohashes. Names resolved fine. Then torrents got stuck at "Waiting for metainfo" and remain like that for half an hour. Here are the Libtorrent session stats. Note that there are several Channels torrents in the background, already downloaded and seeded, zero connections.
@arvidn , can you make something out of these stats?
Also, I noticed that I cannot reproduce this bug on my PC unless I have another instance of Tribler running on my seedbox in the same subnet at my home, behind the same NAT. Tribler running on the seedbox -> the bug triggers sometimes on the PC. Tribler not running on the seedox -> the bug does not trigger on the PC.
@synctext , could it be that another instance of Tribler or another torrent client was running in your home network when you witnessed the freeze?
those counters suggest that the DHT was properly bootstrapped and connected to the network. They also suggested that there were peers connected, and no peers failing with an error (which I would have expected if there were some issue with the ut_metadata
extension, that downloads the .torrent from peers). It's not obvious what's going on. Enabling logging would probably help.
@arvidn , is it possible to enable Libtorrent logging from Python bindings?
yes, set the alert_mask setting to include the peer_log_notification
flag (documented here)
BTW, I've checked Libtorrent versions used in our latest releases:
MacOS | Win64 | |
---|---|---|
Tribler 7.4.4 | 1.2.2 | 1.2.1 |
Tribler 7.5-rc5 | 1.2.2 | 1.2.1 |
:skull: Can't reproduce it anymore :skull: Dozens of restarts, everything runs perfectly on the same PC where yesterday it was triggered every second run :dizzy_face:
I suspect it is only triggered by a very specific race condition. In that case, using stable, deterministic environments (like VMs and app tester) will not suffice. To catch it for good, we'll probably have to produce a specialized "debug" release with enabled debug symbols, full logging and a watchdog that will automatically send the last 5 minutes of logs and some kind of Libtorrent stack trace to the Reporter server.
Accidentally reproduced on Ubuntu at home (Libtorrent 1.2.2):
You know what's funny? When I restarted Tribler, only the OpenSUSE torrent was downloading. Ubuntu was in a "stopped" state. :thinking:
@ichorid Not sure why a download would be "stopped" directly after adding it. Are you sure that you didn't try to stop the download while it was still waiting for the metainfo?
I just did some testing, and it could be that the problem with the download being stuck in "Waiting for metadata" is because we're not receiving any peers from the DHT. To test this I added a call to force_dht_announce
at the bottom of Download.on_add_torrent_alert
, and the download seems to start a lot faster. Could possibly be due to the fact we just did a DHT request when we opened the download dialog.
@egbertbouman , I'm sure I did not press the "stop" button before closing Tribler. Also, I had disabled the download dialog through the settings menu beforehand to reduce the amount of clicking...
hi all, i have an issue with Tribler: all my downloads regularly regress to 0 kb/sec. They pick up again after a while. I've tried to create logs for this to share with the developers, but even with the log option checked in the options, my log folder stays empty. What did i miss? I'm on Windows 10, using latest stable version 7.4.4 from the Tribler.org website. Rik