Skip to content

[Bug] 定时任务报错 #6690

Description

@wangliang181230

MaxKB Version

v2.10.5-lts

Problem Description

错误日志:

2026-08-17 00:00:00 [client_access_num_job INFO] start reset access_num
2026-08-17 00:00:00 [client_access_num_job INFO] end reset access_num
2026-08-17 00:05:00 [clean_chat_job INFO] 开始清理聊天日志
2026-08-17 00:05:00 Job "clean_chat_log_job (trigger: cron[hour='0', minute='5'], next run at: 2026-08-18 00:05:00 CST)" raised an exception
Traceback (most recent call last):
  File "/opt/py3/lib/python3.11/site-packages/django/db/models/sql/query.py", line 2245, in add_fields
    join_info = self.setup_joins(
                ^^^^^^^^^^^^^^^^^
  File "/opt/py3/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1908, in setup_joins
    path, final_field, targets, rest = self.names_to_path(
                                       ^^^^^^^^^^^^^^^^^^^
  File "/opt/py3/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1813, in names_to_path
    raise FieldError(
django.core.exceptions.FieldError: Cannot resolve keyword 'user_id' into field. Choices are: abstract, application, application_id, asker, chat_record_count, chat_user_id, chat_user_type, chatrecord, chatsharelink, create_time, id, ip_address, is_deleted, mark_sum, meta, source, star_num, trample_num, update_time

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/py3/lib/python3.11/site-packages/apscheduler/executors/base.py", line 131, in run_job
    retval = job.func(*job.args, **job.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maxkb-app/apps/common/job/clean_chat_job.py", line 17, in clean_chat_log_job
    clean_chat_log_job_lock()
  File "/opt/maxkb-app/apps/common/utils/lock.py", line 70, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maxkb-app/apps/common/job/clean_chat_job.py", line 43, in clean_chat_log_job_lock
    clean_method(query_conditions)
  File "/opt/maxkb-app/apps/common/job/clean_chat_job.py", line 99, in clean_method
    user_ids = list(chats.values_list("user_id", flat=True).distinct())
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/py3/lib/python3.11/site-packages/django/db/models/query.py", line 1411, in values_list
    clone = self._values(*_fields, **expressions)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/py3/lib/python3.11/site-packages/django/db/models/query.py", line 1365, in _values
    clone.query.set_values(fields)
  File "/opt/py3/lib/python3.11/site-packages/django/db/models/sql/query.py", line 2584, in set_values
    self.add_fields(field_names, True)
  File "/opt/py3/lib/python3.11/site-packages/django/db/models/sql/query.py", line 2286, in add_fields
    raise FieldError(
django.core.exceptions.FieldError: Cannot resolve keyword 'user_id' into field. Choices are: abstract, application, application_id, asker, chat_record_count, chat_user_id, chat_user_type, chatrecord, chatsharelink, create_time, id, ip_address, is_deleted, mark_sum, meta, source, star_num, trample_num, update_time

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions