i2psnark losing progress after being unable to write to disk

Discussions about i2P enabled Bittorrent clients, experience reports and issues
xqapjl
Posts: 30
Joined: Mon Jun 09, 2025 9:40 pm

i2psnark losing progress after being unable to write to disk

Post by xqapjl »

Sometimes torrents complain about not being able to write stuff to the disk and then they stop. After this, some progress is lost. Sometimes pretty much all of what's already downloaded is gone.

This seems to happen more after adding magnet links for some reason, but I'm not sure if that's actually related.

Is anyone else experiencing this?

I don't believe it's actually a disk problem, because if it was I'd expect errors about it in dmesg, which I don't see. If I'm the only one seeing this, it's likely some sort of hardware problem though.

Edit : I forgot to add that this seems to happen more when the system is heavily loaded. Perhaps there is some kind of timeout somewhere that considers a write to have failed if it takes too long?
xHarr
Posts: 4
Joined: Sat Aug 16, 2025 3:10 pm

Re: i2psnark losing progress after being unable to write to disk

Post by xHarr »

Bit of a shot in the dark solution here, but have you tried increasing the memory that i2p's java wrapper has access to? I've found doing that made everything run smoother for me.

It's done by editing /etc/i2p/wrapper.config
-xHarr
xqapjl
Posts: 30
Joined: Mon Jun 09, 2025 9:40 pm

Re: i2psnark losing progress after being unable to write to disk

Post by xqapjl »

xHarr wrote: Sat Aug 16, 2025 3:26 pm Bit of a shot in the dark solution here, but have you tried increasing the memory that i2p's java wrapper has access to? I've found doing that made everything run smoother for me.

It's done by editing /etc/i2p/wrapper.config
Seems like a reasonable guess, thanks!

I'm using i2psnark standalone 2.9.0+ and it doesn't have wrapper.config, but I believe I've found the correct setting in the launch-i2psnark file used to start it.

Code: Select all

# Increase memory to 1024 MB
#JAVA_OPTS='-Xmx1024m'
JAVA_OPTS='-Xmx4096m'
We'll see how it goes!
xHarr
Posts: 4
Joined: Sat Aug 16, 2025 3:10 pm

Re: i2psnark losing progress after being unable to write to disk

Post by xHarr »

Sounds good. Hopefully it should take the edge off.
-xHarr
xqapjl
Posts: 30
Joined: Mon Jun 09, 2025 9:40 pm

Re: i2psnark losing progress after being unable to write to disk

Post by xqapjl »

It was using more than 900MB RAM, so it seemed like a reasonable guess, but increasing it did not fix it.

I tried to increase the amount of allowed open files.

Code: Select all

# Increase memory to 1024 MB
#JAVA_OPTS='-Xmx1024m'
JAVA_OPTS='-Xmx4096m'
ulimit -n 8192
This did not help and it doesn't seem to be possible to increase it beyond 8192. (I have more than 8192 files in active torrents. Perhaps I should decrease that amount?)

Then I lowered total uploader limit from 45 to 30. That didn't help either.

Just in case anyone is wondering what this looks like in the logs:

Code: Select all

(timestamp and some more stuff) ....PeerCoordinator: Error writing to storage [piece 644] for (torrent name here)
* Error writing to storage [piece 644] for (torrent name here)
xqapjl
Posts: 30
Joined: Mon Jun 09, 2025 9:40 pm

Re: i2psnark losing progress after being unable to write to disk

Post by xqapjl »

I tried rebooting, which seemed to help. At least until it happened again.

Another issue I'm seeing is that sometimes when this happens and I to a Force Recheck it can go from something like 99% finished to 12% finished.

Also, sometimes torrents end up in some kind of quasi state where it's both finished and not finished. This does not seem to produce any logs. If I do a recheck on this type of torrent it also tends to lose most of its data.

Another thing that makes me think it's not a hardware issue is that I'd expect to see file system errors, which I don't. It's kind of weird that I seem to be the only one with this problem though.
xqapjl
Posts: 30
Joined: Mon Jun 09, 2025 9:40 pm

Re: i2psnark losing progress after being unable to write to disk

Post by xqapjl »

I believe I may have found the issue.

Code: Select all

$ java --version
openjdk 11.0.28 2025-07-15
OpenJDK Runtime Environment (build 11.0.28+6-post-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 11.0.28+6-post-Debian-1deb11u1, mixed mode, sharing)

Code: Select all

$ sudo apt install openjdk-17-jre

Code: Select all

$ java --version
openjdk 17.0.15 2025-04-15
OpenJDK Runtime Environment (build 17.0.15+6-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.15+6-Debian-1deb11u1, mixed mode, sharing)
Time for some more testing...
xqapjl
Posts: 30
Joined: Mon Jun 09, 2025 9:40 pm

Re: i2psnark losing progress after being unable to write to disk

Post by xqapjl »

At least I got what looks like a potentially more useful error message this time.

Code: Select all

java.io.IOException: Error writing /path/to/file
        at org.klomp.snark.Storage.putPiece(Storage.java:1290)
        at org.klomp.snark.PeerCoordinator.gotPiece(PeerCoordinator.java:1062)
        at org.klomp.snark.PeerState.pieceMessage(PeerState.java:431)
        at org.klomp.snark.PeerConnectionIn.run(PeerConnectionIn.java:152)
        at org.klomp.snark.Peer.runConnection(Peer.java:296)
        at org.klomp.snark.PeerCoordinator$1.run(PeerCoordinator.java:718)
        at java.base/java.lang.Thread.run(Thread.java:840)
        at net.i2p.util.I2PThread.run(I2PThread.java:103)
Caused by: java.io.IOException: Bad file descriptor
        at java.base/java.io.RandomAccessFile.writeBytes(Native Method)
        at java.base/java.io.RandomAccessFile.write(RandomAccessFile.java:558)
        at org.klomp.snark.Storage$TorrentFile.balloonFile(Storage.java:1556)
        at org.klomp.snark.Storage$TorrentFile.access$100(Storage.java:1410)
        at org.klomp.snark.Storage.putPiece(Storage.java:1274)
        ... 7 more
("Bad file descriptor" has been translated from another language. It was the closest similar error message I could find in english, so it's probably correct.)
xqapjl
Posts: 30
Joined: Mon Jun 09, 2025 9:40 pm

Re: i2psnark losing progress after being unable to write to disk

Post by xqapjl »

Looks like I was correct about "Bad file descriptor".

After changing the last line in launch-i2psnark from

Code: Select all

java $JAVA_OPTS -jar i2psnark.jar
to

Code: Select all

LANGUAGE=C java $JAVA_OPTS -jar i2psnark.jar
I got this:

Code: Select all

java.io.IOException: Error writing /path/to/file
        at org.klomp.snark.Storage.putPiece(Storage.java:1290)
        at org.klomp.snark.PeerCoordinator.gotPiece(PeerCoordinator.java:1062)
        at org.klomp.snark.PeerState.pieceMessage(PeerState.java:431)
        at org.klomp.snark.PeerConnectionIn.run(PeerConnectionIn.java:152)
        at org.klomp.snark.Peer.runConnection(Peer.java:296)
        at org.klomp.snark.PeerCoordinator$1.run(PeerCoordinator.java:718)
        at java.base/java.lang.Thread.run(Thread.java:840)
        at net.i2p.util.I2PThread.run(I2PThread.java:103)
Caused by: java.io.IOException: Bad file descriptor
        at java.base/java.io.RandomAccessFile.writeBytes(Native Method)
        at java.base/java.io.RandomAccessFile.write(RandomAccessFile.java:558)
        at org.klomp.snark.Storage$TorrentFile.balloonFile(Storage.java:1556)
        at org.klomp.snark.Storage$TorrentFile.access$100(Storage.java:1410)
        at org.klomp.snark.Storage.putPiece(Storage.java:1274)
        ... 7 more
xqapjl
Posts: 30
Joined: Mon Jun 09, 2025 9:40 pm

Re: i2psnark losing progress after being unable to write to disk

Post by xqapjl »

I noticed that after upgrading java, it seems like I'm not always losing progress when I do a Force Recheck after a failed write.

Progress 🥳

I should probably just reinstall my system and replace it with a distro that has newer versions of stuff.
Post Reply