Skip to content

Receiver does not ack/nack Tasks that can't be found #569

Closed

Description

@anjafr

Taskiq version

0.11.17

Python version

Python 3.11

OS

macOS

What happened?

When encountering a task/a message that can't be found, the TaskIQ receiver logs a warning and then returns (None), see receiver.py
However, this leaves the task/message unacked and forever pending in limbo.
Clearly, if the task can't be found this is not going anywhere and either the broker and/or the result backend should in one way or another be informed.
In our case: we use RabbitMQ as broker and had a handful of "not found" tasks (the reason has been fixed, doesn't really matter) around. They were no longer in queue (due to pre-fetch), so inspecting the message queue or purging it did not help. Terminating the consumer only put those messages back into the queue very briefly, before the re-spawned consumer picked them up again and nothing was gained. (For RabbitMQ specifically, these messages should have been nacked. )
Independent of the exact broker and implementation however this behaviour is problematic: it leaves messages in an undefined state.

Relevant log output

WARNING:receiver.py:119:    task "project:dont_ask_me_how_this_happened_task" is not found. Maybe you forgot to import it?

Broker initialization code

broker = AioPikaBroker(
        url=broker_config.to_url(
            vhost=app_config.name
        ),
        queue_name=app_config.name,
        delayed_message_exchange_plugin=True,
        max_priority=5,
        qos=3,
    )

Activity

  1. yangshuer commented on Dec 29, 2025

    @yangshuer

    遇到了相同的问题。

    [feishu_broker.py]
    from config.config import Config
    from taskiq_aio_pika import AioPikaBroker
    from taskiq_redis import RedisAsyncResultBackend

    feishu_broker = AioPikaBroker(
    Config.rabbitmq,
    queue_name='feishu_queue'
    ).with_result_backend(
    RedisAsyncResultBackend(f"redis://:{Config.redis.password}@{Config.redis.host}:{Config.redis.port}/0",
    result_ex_time=86400,
    max_connection_pool_size=20
    )
    )
    [pdf_parser_broker.py]
    from config.config import Config
    from taskiq_aio_pika import AioPikaBroker
    from taskiq_redis import RedisAsyncResultBackend

    pdf_parser_broker = AioPikaBroker(
    Config.rabbitmq,
    queue_name='pdf_parser_queue'
    ).with_result_backend(
    RedisAsyncResultBackend(f"redis://:{Config.redis.password}@{Config.redis.host}:{Config.redis.port}/1",
    result_ex_time=86400,
    max_connection_pool_size=20
    )
    )

    Main 2025-12-29 13:40:27 +0800 WARNING: Sanic is running in PRODUCTION mode. Consider using '--debug' or '--dev' while actively developing your application.
    2025-12-29 13:40:27 - background_task_service - WARNING - Sanic is running in PRODUCTION mode. Consider using '--debug' or '--dev' while actively developing your application.
    2025-12-29 13:40:30 - background_task_service - INFO - 开始执行每日飞书知识库同步任务...
    Srv 0 2025-12-29 13:40:30 +0800 INFO: Starting worker [452308]
    2025-12-29 13:40:30 - background_task_service - INFO - Starting worker [452308]
    2025-12-29 13:40:30 - background_task_service - INFO - 查询到 2 个活跃的飞书用户
    2025-12-29 13:40:31 - background_task_service - INFO - 已发送任务-获取飞书知识库节点列表-userid:1, appid:cli_a9c90741b3b89bde, space_id:7585116745453210577-任务ID-5228c95b692d4464bbbbd53ea4b1a240
    2025-12-29 13:40:31 - background_task_service - INFO - 已发送任务-获取飞书知识库节点列表-userid:2, appid:cli_a9c64a020eb81bd8, space_id:7533531698911707155-任务ID-1665bf0787b7420bb45489afbbb82b40
    2025-12-29 13:40:31 - background_task_service - INFO - 成功发送 2 个飞书任务
    2025-12-29 13:40:31 - background_task_service - INFO - 每日飞书知识库同步任务已发送,共 2 个任务
    create_parser_task_knowledge_ids [40, 41]
    2025-12-29 13:41:14 - background_task_service - INFO - 已发送任务:afca4fad640f4c0a9042e87ba527d1f2
    2025-12-29 13:41:14 - background_task_service - INFO - 已发送任务:2f0ba022f41748149f8d78ede39b1299
    create_parser_task_knowledge_ids []

    (rag) yang@YX-PC:~/MyWorkFolder/graph-rag-doc-management$ taskiq worker --ack-type when_saved --workers 1 backend.src.task.get_feishu_task.broker:feishu_broker backend.src.task.get_feishu_task.tasks
    [2025-12-29 13:38:54,246][taskiq.worker][INFO ][MainProcess] Pid of a main process: 451747
    [2025-12-29 13:38:54,246][taskiq.worker][INFO ][MainProcess] Starting 1 worker processes.
    [2025-12-29 13:38:54,249][taskiq.process-manager][INFO ][MainProcess] Started process worker-0 with pid 451749
    [2025-12-29 13:38:54,510][taskiq.worker][INFO ][worker-0] Importing tasks from module backend.src.task.get_feishu_task.tasks
    [2025-12-29 13:38:55,603][qcloud_cos.cos_client][INFO ][worker-0] generate built-in connection pool success. maxsize=10,10
    [2025-12-29 13:38:55,603][qcloud_cos.cos_client][INFO ][worker-0] bound built-in connection pool when new client. maxsize=10,10
    2025-12-29 13:38:55 - get_feishu_task - INFO - Listening started.
    2025-12-29 13:40:31 - get_feishu_task - INFO - Executing task backend.src.task.get_feishu_task.tasks:get_feishu_knowledge_task with ID: 5228c95b692d4464bbbbd53ea4b1a240
    2025-12-29 13:40:35 - get_feishu_task - INFO - Executing task backend.src.task.get_feishu_task.tasks:get_feishu_knowledge_task with ID: 1665bf0787b7420bb45489afbbb82b40
    2025-12-29 13:41:03 - get_feishu_task - INFO - put object, url=:https://pro-brand-agent-barre-1253290912.cos.ap-beijing.myqcloud.com/OcUXdWv67oHNjBxq1B8c0VlMnXg-test.pdf ,headers=:{}
    2025-12-29 13:41:04 - get_feishu_task - INFO - 新增知识OcUXdWv67oHNjBxq1B8c0VlMnXg-test.pdf
    2025-12-29 13:41:05 - get_feishu_task - INFO - put object, url=:https://pro-brand-agent-barre-1253290912.cos.ap-beijing.myqcloud.com/RLxnbSmoyo8kwOx2n8ecCGO1nlg-20250117-153622.jpeg ,headers=:{}
    2025-12-29 13:41:05 - get_feishu_task - INFO - 新增知识RLxnbSmoyo8kwOx2n8ecCGO1nlg-20250117-153622.jpeg
    2025-12-29 13:41:14 - get_feishu_task - WARNING - task "backend.src.task.pdf_parser_task.tasks:pdf_parser_task" is not found. Maybe you forgot to import it?
    2025-12-29 13:41:14 - get_feishu_task - WARNING - task "backend.src.task.pdf_parser_task.tasks:pdf_parser_task" is not found. Maybe you forgot to import it?

    (rag) yang@YX-PC:~/MyWorkFolder/graph-rag-doc-management$ taskiq worker --ack-type when_saved --workers 2 backend.src.task.pdf_parser_task.broker:pdf_parser_broker backend.src.task.pdf_parser_task.tasks
    [2025-12-29 13:39:24,850][taskiq.worker][INFO ][MainProcess] Pid of a main process: 451881
    [2025-12-29 13:39:24,850][taskiq.worker][INFO ][MainProcess] Starting 2 worker processes.
    [2025-12-29 13:39:24,853][taskiq.process-manager][INFO ][MainProcess] Started process worker-0 with pid 451884
    [2025-12-29 13:39:24,855][taskiq.process-manager][INFO ][MainProcess] Started process worker-1 with pid 451886
    [2025-12-29 13:39:25,062][taskiq.worker][INFO ][worker-1] Importing tasks from module backend.src.task.pdf_parser_task.tasks
    [2025-12-29 13:39:25,062][taskiq.worker][INFO ][worker-0] Importing tasks from module backend.src.task.pdf_parser_task.tasks
    2025-12-29 13:39:25 - pdf_parser_task - INFO - Listening started.
    2025-12-29 13:39:25 - pdf_parser_task - INFO - Listening started.
    2025-12-29 13:40:31 - pdf_parser_task - WARNING - task "backend.src.task.get_feishu_task.tasks:get_feishu_knowledge_task" is not found. Maybe you forgot to import it?
    2025-12-29 13:40:31 - pdf_parser_task - WARNING - task "backend.src.task.get_feishu_task.tasks:get_feishu_knowledge_task" is not found. Maybe you forgot to import it?
    2025-12-29 13:41:14 - pdf_parser_task - INFO - Executing task backend.src.task.pdf_parser_task.tasks:pdf_parser_task with ID: afca4fad640f4c0a9042e87ba527d1f2
    知识id40执行pdf_parser_task
    2025-12-29 13:41:14 - pdf_parser_task - INFO - Executing task backend.src.task.pdf_parser_task.tasks:pdf_parser_task with ID: 2f0ba022f41748149f8d78ede39b1299
    知识id41执行pdf_parser_task

    Image
  2. added a commit that references this issue on Sep 14, 2026
    a81466a
  3. added a commit that references this issue on Oct 5, 2026
    2453b4a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions