[18.0] queue_job: remove_db -> psycopg2.DatabaseError: out of memory for query result

未关闭
#1,026 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
22/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
postgresql, python

调研方向

The traceback points to initialize_databases in queue_job/jobrunner/runner.py (around line 403), which iterates a cursor over every queue_job row, and to remove_db in queue_job/jobrunner/channels.py (around line 1139), which copies _jobs_by_uuid into a list. Read how the job loading query is built and how the channel manager stores jobs. Done means the runner survives a backlog of millions of pending jobs without loading them all into memory, ideally with a test or a reproduction script that shows the memory use.

由索引模型根据 Issue 内容生成。

描述

bug

Module

queue_job

Describe the bug

2026-11-01 13:40:47,969 147583 ERROR ? odoo.addons.queue_job.jobrunner.runner: exception: sleeping 5s and retrying
--
Traceback (most recent call last):
File "/usr/local/src/metricwise/oca/queue/queue_job/jobrunner/runner.py", line 502, in run
self.initialize_databases()
File "/usr/local/src/metricwise/oca/queue/queue_job/jobrunner/runner.py", line 403, in initialize_databases
for job_data in cr:
psycopg2.DatabaseError: out of memory for query result
2026-11-01 13:40:47,972 147583 WARNING ? odoo.addons.queue_job.jobrunner.runner: error closing database odoo
Traceback (most recent call last):
File "/usr/local/src/metricwise/oca/queue/queue_job/jobrunner/runner.py", line 390, in close_databases
self.channel_manager.remove_db(db_name)
File "/usr/local/src/metricwise/oca/queue/queue_job/jobrunner/channels.py", line 1139, in remove_db
for job in list(self._jobs_by_uuid.values()):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
MemoryError
>>> env.cr.execute('SELECT state, count(*) FROM queue_job GROUP BY state')
>>> env.cr.fetchall()
[('done', 81056), ('enqueued', 1), ('failed', 150), ('pending', 4009271), ('wait_dependencies', 3)]

To Reproduce

Affected versions: 18.0.3.1.3

Steps to reproduce the behavior:

  1. Queue up several million jobs.
  2. Attempt to run them.
主要语言
Python
星标
271
派生
602
平均合并
4 天 4 小时
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OCA/queue 的其他 Issue

查看 OCA/queue 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。