crazy-max / docker-rtorrent-rutorrent

rTorrent and ruTorrent Docker image
MIT License
503 stars 112 forks source link

rtorrent always preallocates started files #395

Open Pheromir opened 2 months ago

Pheromir commented 2 months ago

Support guidelines

I've found a bug and checked that ...

Description

When starting a download, rtorrent always seems to preallocate the files on the disk, even if option is explicitly set to 0 in config

Expected behaviour

Files shouldn't get preallocated if option not set to 1 or 2

Actual behaviour

Files always get preallocated after they started downloading

Steps to reproduce

  1. Add torrent as stopped
  2. set priority for all files except one to "do not download"
  3. if any other file is included in the pieces required for the wanted file, the unwanted file gets completery preallocated on the disk.
  4. You should now have a file with (for example) 0.5% download progress you didn't want and a completely preallocated file on the disk.

Docker info

Client:
 Version:    24.0.9
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc.)
    Version:  v2.29.2
    Path:     /usr/local/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 43
  Running: 40
  Paused: 0
  Stopped: 3
 Images: 56
 Server Version: 24.0.9
 Storage Driver: btrfs
  Btrfs:
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7c3aca7a610df76212171d200ca3811ff6096eb8
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.1.106-Unraid
 Operating System: Slackware 15.0 x86_64 (post 15.0 -current)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.26GiB
 Name: NAS
 ID: f5a0efb4-349c-4cf3-b081-a5c9de79d0cc
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

WARNING: No swap limit support

Docker Compose config

name: rtorrent-rutorrent
services:
  rtorrent:
    container_name: rtorrent
    environment:
      AUTH_DELAY: 0s
      LOG_ACCESS: "true"
      LOG_IP_VAR: remote_addr
      MAX_FILE_UPLOADS: "50"
      MEMORY_LIMIT: 256M
      OPCACHE_MEM_SIZE: "128"
      PGID: "100"
      PUID: "1000"
      REAL_IP_FROM: 0.0.0.0/32
      REAL_IP_HEADER: X-Forwarded-For
      RT_DHT_PORT: "xxx"
      RT_INC_PORT: "xxx"
      RT_LOG_EXECUTE: "true"
      RT_LOG_LEVEL: debug
      RT_LOG_XMLRPC: "false"
      RT_RECEIVE_BUFFER_SIZE: 8M
      RT_SEND_BUFFER_SIZE: 8M
      RT_SESSION_SAVE_SECONDS: "3600"
      RU_DO_DIAGNOSTIC: "true"
      RU_FORBID_USER_SETTINGS: "false"
      RU_HTTP_TIME_OUT: "30"
      RU_HTTP_USE_GZIP: "true"
      RU_HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0
      RU_LOCALE: UTF8
      RU_LOG_FILE: /data/rutorrent/rutorrent.log
      RU_LOG_RPC_CALLS: "false"
      RU_LOG_RPC_FAULTS: "true"
      RU_OVERWRITE_UPLOADED_TORRENTS: "false"
      RU_PHP_GZIP_LEVEL: "2"
      RU_PHP_USE_GZIP: "false"
      RU_RPC_TIME_OUT: "5"
      RU_SAVE_UPLOADED_TORRENTS: "true"
      RU_SCHEDULE_RAND: "10"
      RUTORRENT_AUTHBASIC_STRING: Restricted access
      RUTORRENT_PORT: "xxx"
      TZ: xxx
      UPLOAD_MAX_SIZE: 32M
      WAN_IP_CMD: "false"
      WEBDAV_AUTHBASIC_STRING: Restricted access
      WEBDAV_PORT: "xxx"
      XMLRPC_AUTHBASIC_STRING: Restricted access
      XMLRPC_PORT: "xxx"
    image: crazymax/rtorrent-rutorrent:latest
    network_mode: container:gluetun-rtorrent
    restart: unless-stopped
    stop_grace_period: 1m0s
    ulimits:
      nofile:
        soft: 32000
        hard: 40000
      nproc: 65535
    volumes:
      - type: bind
        source: /mnt/user/appdata/dockerfiles/rtorrent/data
        target: /data
        bind:
          create_host_path: true
      - type: bind
        source: /mnt/user/storage/Libraries
        target: /media
        bind:
          create_host_path: true
      - type: bind
        source: /mnt/user/appdata/dockerfiles/rtorrent/passwd
        target: /passwd
        bind:
          create_host_path: true
  rtorrent-logs:
    command:
      - bash
      - -c
      - tail -f /log/*.log
    container_name: rtorrent-logs
    depends_on:
      rtorrent:
        condition: service_started
        required: true
    image: bash
    network_mode: none
    restart: unless-stopped
    volumes:
      - type: bind
        source: /mnt/user/appdata/dockerfiles/rtorrent/data/rtorrent/log
        target: /log
        bind:
          create_host_path: true

Logs

They don't seem to contain any useful info for this problem, but here's the part of the logs where I added the torrent:

1726356987 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_list: added tracker (group:0 url:http://xxx)
1726356987 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_list: added tracker (group:1 url:http://xxx)
1726356987 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_list: added tracker (group:2 url:udp://xxx)
1726356987 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_list: added tracker (group:3 url:udp://xxx)
1726356987 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_list: added tracker (group:4 url:udp://xxx)
1726356987 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_list: added tracker (group:5 url:udp://xxx)
1726356987 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_list: added tracker (group:6 url:udp://xxx)
1726356987 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_list: added tracker (group:7 url:dht://)
1726356987 I Upload unchoked slots adjust; currently:14 adjust:0
1726356987 I Upload unchoked slots adjust; currently:14 adjust:0
1726356987 I Download unchoked slots adjust; currently:5 adjust:0
1726356987 I Download unchoked slots adjust; currently:5 adjust:0
1726356987 I 94E9C035E69220600E41E7D73661B289550D758C->download_list: Closing download directly.
1726356987 I 94E9C035E69220600E41E7D73661B289550D758C->download_list: Inserting download.
1726356988 I Download unchoked slots adjust; currently:5 adjust:1
1726356995 I Download unchoked slots adjust; currently:6 adjust:-1
1726357001 I 94E9C035E69220600E41E7D73661B289550D758C->download_list: Opening download.
1726357001 I 94E9C035E69220600E41E7D73661B289550D758C->download: Opening torrent: flags:ffffffff.
1726357001 I 94E9C035E69220600E41E7D73661B289550D758C->file_list: Opening.
1726357001 I 94E9C035E69220600E41E7D73661B289550D758C->chunk_list: Resizing: from:0 to:3796.
1726357001 I 94E9C035E69220600E41E7D73661B289550D758C->download_list: Resuming download: flags:0.
1726357001 I 94E9C035E69220600E41E7D73661B289550D758C->download_list: Opening download.
1726357001 I 94E9C035E69220600E41E7D73661B289550D758C->download: Checking hash: allocated:0 try_quick:1.
1726357001 I 94E9C035E69220600E41E7D73661B289550D758C->hash_torrent: Start: position:0 size:3796 try_quick:1.
1726357001 I 94E9C035E69220600E41E7D73661B289550D758C->hash_torrent: Completed (normal): position:3796 try_quick:1.
1726357002 I 94E9C035E69220600E41E7D73661B289550D758C->hash_torrent: Confirm checked.
1726357002 I 94E9C035E69220600E41E7D73661B289550D758C->download_list: Hash done.
1726357002 I 94E9C035E69220600E41E7D73661B289550D758C->download_list: Resuming download: flags:0.
1726357002 I 94E9C035E69220600E41E7D73661B289550D758C->download: Starting torrent: flags:0.
1726357002 I 94E9C035E69220600E41E7D73661B289550D758C->file_list: Opening.
1726357002 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_controller: Called enable with 8 trackers.
1726357002 I 94E9C035E69220600E41E7D73661B289550D758C->download: Setting new baseline on start: uploaded:0 completed:0.
1726357002 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_controller: Sending started event.
1726357002 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_list: sending 'started (group:0 url:http://xxx)
1726357003 I 94E9C035E69220600E41E7D73661B289550D758C->tracker_list: received 50 peers (url:http://xxx)
1726357004 I Download unchoked slots adjust; currently:5 adjust:1
1726357004 I Download unchoked slots adjust; currently:6 adjust:1
1726357004 I Download unchoked slots adjust; currently:7 adjust:1
1726357004 I Download unchoked slots adjust; currently:8 adjust:1
1726357004 I Download unchoked slots adjust; currently:9 adjust:1
1726357005 I Download unchoked slots adjust; currently:10 adjust:1
1726357005 I Download unchoked slots adjust; currently:11 adjust:-1
1726357005 I Download unchoked slots adjust; currently:10 adjust:1
1726357005 I Download unchoked slots adjust; currently:11 adjust:-1
1726357005 I Download unchoked slots adjust; currently:10 adjust:1
1726357005 I Download unchoked slots adjust; currently:11 adjust:1

Additional info

I also made sure that the .rtlocal.rc file within the container says "system.file.allocate.set = 0". Not sure if it's a problem with the image or the rtorrent build, but I don't think that I can test it properly without docker here.

Screenshot of the allocated file on the filesystem, with the incomplete files in rtorrent: grafik

stickz commented 2 months ago

Have you read the documentation about how to use the pre-allocate feature? I don't see the environment variable in your config.

https://github.com/crazy-max/docker-rtorrent-rutorrent/tree/master?tab=readme-ov-file#rtorrent-disk-space-preallocation

Pheromir commented 2 months ago

Yes, had it added earlier, but removed it later on, as the documentation states that 0 is the default behaviour (and looking into the rtlocal config in the container seemed to confirm that).

Pheromir commented 2 months ago

Added the EnvVar again and tested the download. Can confirm, that it still happens.

stickz commented 2 months ago

I just tested this outside the docker container. Option 2 works properly. Option 0 always behaves as option 1. This is a rTorrent issue.

Pheromir commented 2 months ago

Thanks for testing! Does it have anything to do with the latest commit you reversed, or do you want me to open a separate issue on your repo?

stickz commented 2 months ago

Please allow further time to test the vanilla rakshasa version of rTorrent. I'm almost sure the issue started there.

If this is the case, the best path forward for a solution is to request a fix there and backport it to rtorrent stickz.

Thanks for testing! Does it have anything to do with the latest commit you reversed,

Nope, I'm working on resolving a separate software crash with torrent rechecking.