Closed k4rli closed 1 month ago
I had same issues post 0.9.0 - worth checking if 0.9.3 has same issues. I solved by adding some Postgres config options and slimming down size of database. Will add steps I took when I'm next at my laptop
Hi,
When I start the container, some DB operation is infinitely failing
This isn't the case - the operation has been cancelled and this isn't an error. A few people have pointed this out though and there may be something that can be done to make the logs less noisy.
CPU usage + RAM go to 100% rapidly
Please see the release notes of 0.9.0, the queue is re-indexing torrents so they work with the new ordering feature, which will use system resources while this is happening. As features are added, we sometimes need to run a maintenance task such as this to bring the database up-to-date. Of course it's ideal to keep these to a minimum, because when they are needed many users will have a big database that needs updating.
Cannot use Bitmagnet anymore at all
If you allow the queue to work down (see progress on the /metrics
endpoint), usage should return to normal. If the app has become unusable, clearing the queue (by manually deleting from the queue_jobs
table) should also return things to normal (but ordering won't work until this job has happened). It's worth reviewing if your system configuration and hardware is suitable for the size of database you're running. A few people had issues with 0.9.0 but most have reported it resolved in 0.9.3. While efficiency improvements can be made in the code, we can't test all the varieties of environment it will be running in. What hardware are you running Bitmagnet on, what type of disk is the database running on and roughly how many torrents do you have indexed?
Anyone still having issues, please let me know if v0.9.4 is any better? https://github.com/bitmagnet-io/bitmagnet/releases/tag/v0.9.4
Again please bear in mind that any unusual load will be due to queue jobs running. The health of this can be checked at the /metrics
endpoint. There is work underway to expose some of these inner workings in the UI to make it less opaque as to what is going on.
Seems good for me with the 0.9.4 image. Container starts up and stays calm
Maybe it is doing the maintenance or migrations currently. I'll let it run for a while. For now Postgres was still at 60% CPU, just without the continuous logs.
Seems good to me now since 0.9.4. CPU usage is 1-2% at idle with a 7900x and 15M crawled entries.
Describe the bug
When I start the container, some DB operation is infinitely failing and CPU usage + RAM go to 100% rapidly. Cannot use Bitmagnet anymore at all. This initially started happening ~3 weeks ago and I haven't used it since. Tried with latest image and still happens.
To Reproduce
Latest version Docker image and using the same database since the earliest versions of this.
Logs
Some words in queries have been substituted with an asterisk. ```log bitmagnet-postgres | 2024-06-30 18:49:33.785 UTC [636] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, 'syren <-> de <-> mer <-> sharing <-> my <-> wife <-> r <-> n <-> centurion <-> * <-> * <-> * <-> *'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'xxx' AND ("content"."release_date" >= '2022-01-01 00:00:00' AND "content"."release_date" < '2023-01-01 00:00:00') AND content.tsv @@ '* <-> de <-> mer <-> * <-> my <-> * <-> r <-> n <-> * <-> * <-> * <-> * <-> *'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:33.785 UTC [636] LOG: could not send data to client: Broken pipe bitmagnet-postgres | 2024-06-30 18:49:33.785 UTC [636] FATAL: connection to client lost bitmagnet-postgres | 2024-06-30 18:49:33.788 UTC [639] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:33.788 UTC [639] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, '* <-> 20 <-> 12 <-> 02 <-> hime <-> marie <-> december'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = '*' AND ("content"."release_date" >= '2020-01-01 00:00:00' AND "content"."release_date" < '2021-01-01 00:00:00') AND content.tsv @@ '* <-> 20 <-> 12 <-> 02 <-> hime <-> marie <-> december'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:33.795 UTC [642] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:33.795 UTC [642] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, '* <-> * <-> deep <-> space <-> * <-> stagione <-> 5'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'movie' AND ("content"."release_date" >= '2002-01-01 00:00:00' AND "content"."release_date" < '2003-01-01 00:00:00') AND content.tsv @@ 'star <-> trek <-> deep <-> space <-> nine <-> stagione <-> 5'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:33.806 UTC [645] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:33.806 UTC [645] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, 'futbol <-> cheom <-> obzor <-> matchei <-> 8 <-> i <-> tur <-> 2 <-> i <-> den_sq_ <-> 16 <-> 10'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'tv_show' AND ("content"."release_date" >= '2023-01-01 00:00:00' AND "content"."release_date" < '2024-01-01 00:00:00') AND content.tsv @@ 'futbol <-> cheom <-> obzor <-> matchei <-> 8 <-> i <-> tur <-> 2 <-> i <-> den_sq_ <-> 16 <-> 10'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:33.807 UTC [645] LOG: could not send data to client: Broken pipe bitmagnet-postgres | 2024-06-30 18:49:33.807 UTC [645] FATAL: connection to client lost bitmagnet-postgres | 2024-06-30 18:49:34.179 UTC [653] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:34.179 UTC [653] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, '2021 <-> 8 <-> 23 <-> Huan <-> Qi <-> Tan <-> Hua <-> Di <-> Yi <-> Chang <-> Shou <-> Fei <-> Fang <-> 288 <-> Jin <-> Bi <-> Jing <-> Pin <-> Bao <-> Ma <-> Yan <-> Jing <-> Nu <-> Yan <-> Jiu <-> Sheng <-> Sao <-> De <-> Bu <-> Yao <-> Bu <-> Yao <-> Gong <-> Wu <-> Yuan <-> Fu <-> Qi <-> Fan <-> Chang <-> Xiu'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'tv_show' AND ("content"."release_date" >= '2021-01-01 00:00:00' AND "content"."release_date" < '2022-01-01 00:00:00') AND content.tsv @@ '2021 <-> 8 <-> 23 <-> Huan <-> Qi <-> Tan <-> Hua <-> Di <-> Yi <-> Chang <-> Shou <-> Fei <-> Fang <-> 288 <-> Jin <-> Bi <-> Jing <-> Pin <-> Bao <-> Ma <-> Yan <-> Jing <-> Nu <-> Yan <-> Jiu <-> Sheng <-> Sao <-> De <-> Bu <-> Yao <-> Bu <-> Yao <-> Gong <-> Wu <-> Yuan <-> Fu <-> Qi <-> Fan <-> Chang <-> Xiu'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:34.179 UTC [653] LOG: could not send data to client: Broken pipe bitmagnet-postgres | 2024-06-30 18:49:34.179 UTC [653] FATAL: connection to client lost bitmagnet-postgres | 2024-06-30 18:49:34.183 UTC [651] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:34.183 UTC [651] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, 'milfslikeitbig <-> nina <-> elle <-> have <-> your <-> cock <-> and <-> eat <-> it <-> too <-> 21 <-> 08'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'xxx' AND ("content"."release_date" >= '2018-01-01 00:00:00' AND "content"."release_date" < '2019-01-01 00:00:00') AND content.tsv @@ '* <-> * <-> * <-> have <-> your <-> * <-> and <-> eat <-> it <-> too <-> 21 <-> 08'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:34.183 UTC [651] LOG: could not send data to client: Broken pipe bitmagnet-postgres | 2024-06-30 18:49:34.183 UTC [651] FATAL: connection to client lost bitmagnet-postgres | 2024-06-30 18:49:34.218 UTC [657] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:34.218 UTC [657] STATEMENT: SELECT EXISTS(SELECT * FROM "content" WHERE "content"."type" = 'xxx' AND ("content"."release_date" >= '2012-01-01 00:00:00' AND "content"."release_date" < '2013-01-01 00:00:00') AND content.tsv @@ 'brazzers <-> big <-> tits <-> in <-> uniform <-> shyla <-> stylez <-> happy <-> fuck <-> day <-> september <-> 22'::tsquery) bitmagnet-postgres | 2024-06-30 18:49:34.218 UTC [657] LOG: could not send data to client: Broken pipe bitmagnet-postgres | 2024-06-30 18:49:34.218 UTC [657] FATAL: connection to client lost bitmagnet-postgres | 2024-06-30 18:49:34.549 UTC [663] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:34.549 UTC [663] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, 'judith <-> szucs <-> mtv'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'movie' AND ("content"."release_date" >= '2003-01-01 00:00:00' AND "content"."release_date" < '2004-01-01 00:00:00') AND content.tsv @@ 'judith <-> szucs <-> mtv'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:34.577 UTC [668] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:34.577 UTC [668] STATEMENT: SELECT EXISTS(SELECT * FROM "content" WHERE "content"."type" = 'tv_show' AND ("content"."release_date" >= '2020-01-01 00:00:00' AND "content"."release_date" < '2021-01-01 00:00:00') AND content.tsv @@ 'yinyleon <-> aamteur <-> wife <-> is <-> tenderly <-> awakened <-> 07 <-> 13 <-> 20 <-> mp4'::tsquery) bitmagnet-postgres | 2024-06-30 18:49:34.577 UTC [668] LOG: could not send data to client: Broken pipe bitmagnet-postgres | 2024-06-30 18:49:34.577 UTC [668] FATAL: connection to client lost bitmagnet-postgres | 2024-06-30 18:49:34.911 UTC [675] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:34.911 UTC [675] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, 'Hua <-> Sheng <-> Jiang <-> Xi <-> Ying <-> the <-> peanut <-> butter <-> falcon'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'movie' AND ("content"."release_date" >= '2019-01-01 00:00:00' AND "content"."release_date" < '2020-01-01 00:00:00') AND content.tsv @@ 'Hua <-> Sheng <-> Jiang <-> Xi <-> Ying <-> the <-> peanut <-> butter <-> falcon'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:34.917 UTC [678] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:34.917 UTC [678] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, 'sniper <-> g <-> r <-> i <-> t <-> global <-> response <-> and <-> intelligence <-> team'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'movie' AND ("content"."release_date" >= '2023-01-01 00:00:00' AND "content"."release_date" < '2024-01-01 00:00:00') AND content.tsv @@ 'sniper <-> g <-> r <-> i <-> t <-> global <-> response <-> and <-> intelligence <-> team'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:34.968 UTC [666] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:34.968 UTC [666] STATEMENT: SELECT EXISTS(SELECT * FROM "content" WHERE "content"."type" = 'xxx' AND ("content"."release_date" >= '2018-01-01 00:00:00' AND "content"."release_date" < '2019-01-01 00:00:00') AND content.tsv @@ '* <-> aka <-> * <-> * <-> ria <-> blonde <-> * <-> * <-> * <-> enjoys <-> * <-> in <-> * <-> * <-> 09 <-> 04'::tsquery) bitmagnet-postgres | 2024-06-30 18:49:34.969 UTC [666] LOG: could not send data to client: Broken pipe bitmagnet-postgres | 2024-06-30 18:49:34.969 UTC [666] FATAL: connection to client lost bitmagnet-postgres | 2024-06-30 18:49:34.970 UTC [696] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:34.970 UTC [696] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, 'sui <-> dhaaga'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'movie' AND ("content"."release_date" >= '2018-01-01 00:00:00' AND "content"."release_date" < '2019-01-01 00:00:00') AND content.tsv @@ 'sui <-> dhaaga'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:34.994 UTC [704] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:34.994 UTC [704] STATEMENT: SELECT *, ts_rank_cd(content.tsv, $1::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = $2 AND content.tsv @@ $3::tsquery ORDER BY "_order_0" DESC LIMIT $4 bitmagnet-postgres | 2024-06-30 18:49:34.999 UTC [702] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:34.999 UTC [702] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, '* <-> *'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'movie' AND ("content"."release_date" >= '2020-01-01 00:00:00' AND "content"."release_date" < '2021-01-01 00:00:00') AND content.tsv @@ '* <-> *'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:35.372 UTC [708] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:35.372 UTC [708] STATEMENT: SELECT *, ts_rank_cd(content.tsv, $1::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = $2 AND ("content"."release_date" >= $3 AND "content"."release_date" < $4) AND content.tsv @@ $5::tsquery ORDER BY "_order_0" DESC LIMIT $6 bitmagnet-postgres | 2024-06-30 18:49:35.393 UTC [711] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:35.393 UTC [711] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, 'top <-> gear <-> audio <-> e <-> video <-> sincronizzati <-> 12x08'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'tv_show' AND ("content"."release_date" >= '2008-01-01 00:00:00' AND "content"."release_date" < '2009-01-01 00:00:00') AND content.tsv @@ 'top <-> gear <-> audio <-> e <-> video <-> sincronizzati <-> 12x08'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:35.405 UTC [693] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:35.405 UTC [693] STATEMENT: SELECT EXISTS(SELECT * FROM "content" WHERE "content"."type" = 'tv_show' AND content.tsv @@ 'www <-> scenetime <-> com <-> * <-> *'::tsquery) bitmagnet-postgres | 2024-06-30 18:49:35.428 UTC [717] ERROR: canceling statement due to user request bitmagnet-postgres | 2024-06-30 18:49:35.428 UTC [717] STATEMENT: WITH "cte" AS MATERIALIZED (SELECT *, ts_rank_cd(content.tsv, 'ho <-> mu <-> re <-> su <-> Zhong <-> Xue <-> Sheng <-> 08 <-> 07 <-> 12'::tsquery) AS _order_0 FROM "content" WHERE "content"."type" = 'tv_show' AND ("content"."release_date" >= '2008-01-01 00:00:00' AND "content"."release_date" < '2009-01-01 00:00:00') AND content.tsv @@ 'ho <-> mu <-> re <-> su <-> Zhong <-> Xue <-> Sheng <-> 08 <-> 07 <-> 12'::tsquery LIMIT 50000),"cte_count" AS MATERIALIZED (SELECT COUNT(*) AS total_count FROM cte) SELECT * FROM "cte" WHERE (SELECT MAX(total_count) FROM cte_count) < 50000 ORDER BY "_order_0" DESC LIMIT $1 bitmagnet-postgres | 2024-06-30 18:49:35.429 UTC [717] LOG: could not send data to client: Broken pipe bitmagnet-postgres | 2024-06-30 18:49:35.429 UTC [717] FATAL: connection to client lost ^Ccanceled ```My docker-compose.yml
``` services: bitmagnet: image: ghcr.io/bitmagnet-io/bitmagnet:latest container_name: bitmagnet ports: - "3333:3333" restart: unless-stopped environment: - POSTGRES_HOST=bitmagnet-postgres - POSTGRES_PASSWORD=postgres - REDIS_ADDR=bitmagnet-redis:6379 - TMDB_API_KEY=private - LOG_LEVEL=info - DHT_CRAWLER_SCALING_FACTOR=5 command: - worker - run - --keys=http_server - --keys=queue_server # disable the next line to run without DHT crawler - --keys=dht_crawler networks: - homenet - bitmagnetnet depends_on: postgres: condition: service_healthy redis: condition: service_healthy labels: - "traefik.enable=true" - "traefik.docker.network=homenet" - "traefik.http.routers.bitmagnet.rule=Host(`private`)" - "traefik.http.routers.bitmagnet.entrypoints=https" - "traefik.http.services.bitmagnet.loadbalancer.server.port=3333" - "traefik.http.routers.bitmagnet.tls=true" - "traefik.http.routers.bitmagnet.tls.certresolver=letsencrypt" - "traefik.http.routers.bitmagnet.middlewares=basic-auth-global@file" postgres: image: postgres:16-alpine container_name: bitmagnet-postgres shm_size: 3g volumes: - ./data/postgres:/var/lib/postgresql/data ports: - "5433:5432" restart: unless-stopped environment: - POSTGRES_PASSWORD=private - POSTGRES_DB=bitmagnet - PGUSER=postgres healthcheck: test: - CMD-SHELL - pg_isready start_period: 20s interval: 10s networks: - homenet - bitmagnetnet labels: - "traefik.enable=false" redis: image: redis:7-alpine container_name: bitmagnet-redis hostname: bitmagnet-redis volumes: - ./data/redis:/data restart: unless-stopped entrypoint: - redis-server - --save 60 1 healthcheck: test: - CMD - redis-cli - ping start_period: 20s interval: 10s networks: - bitmagnetnet labels: - "traefik.enable=false" networks: homenet: external: true bitmagnetnet: internal: true ```Expected behavior
Works as before and doesn't blow up my PC.
Environment Information (Required)
(e.g. dht_crawler.save_pieces: true)
- none