gc: drop jobs tables whose table no longer exists
維護者通常 4 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 55/100
研究方向
Start by reading dj.gc and the existing GarbageCollector.collect() implementation to understand how reports and errors are represented. Trace how schema tables identify Computed and Imported tables and how their tier prefixes map to ~~ jobs tables; the issue names no files or tests, so locate the relevant tests before implementation. Done means dry-run reports all orphaned jobs tables without changes, execution drops only those tables, and the acceptance cases pass on MySQL and PostgreSQL.
由索引模型根據 Issue 內容生成。
描述
Summary
A jobs table, ~~<name>, can outlive the auto-populated table it belongs to: #1601 shows it for drop(), and its comments show it for a cascading drop and for a drop through a virtual module. It also happens with tables dropped by an earlier release, by another process, or by hand. A jobs table left behind keeps its records and its primary key, and a table declared later under the same name inherits them (#1601).
Fixing drop() stops new leftovers, but not the ones already in existing schemas. A garbage-collection step would remove those too, whatever path left them, the same way dj.gc already handles orphaned objects in storage.
Proposal
A function in dj.gc, separate from GarbageCollector because jobs tables live in the database and not in a store:
dj.gc.collect_jobs_tables(schema) # report only (dry_run=True by default)
dj.gc.collect_jobs_tables(schema, dry_run=False) # drop the orphans
- For each schema, list the
~~%tables and the Computed and Imported tables. A jobs table is orphaned when no Computed or Imported table has its name, after the tier prefix is stripped (__nameor_namefor~~name). dry_run=Trueis a read-only report;dry_run=Falsedrops the orphaned jobs tables, and nothing else.- Return a report in the style of
GarbageCollector.collect(): the number of jobs tables found, the orphaned ones by full name, the number dropped, and errors.
Out of scope
A jobs table whose table exists but whose primary key no longer matches it, after a table is re-declared under the same name. That is the check in AutoPopulate.jobs that #1601 proposes; a GC step cannot tell a stale jobs table from a current one by name alone.
Acceptance
- With
dry_run=Truenothing changes; the report lists every orphaned jobs table. - With
dry_run=Falseexactly those are dropped. Jobs tables of existing Computed and Imported tables are kept, along with their records. - After
Stage1.drop()cascades toStage2(the reproduction in #1601's comments), both~~stage1and~~stage2are reported and dropped. - Works on MySQL and on PostgreSQL.
- 主要語言
- Python
- 星號
- 197
- 分支
- 101
- 平均合併
- 3 天 8 小時
- 30 天內合併 PR
- 28
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
datajoint/datajoint-python 的其他 Issue
-
len() of an expression with an empty primary key generates invalid SQL可能已有人在做 @dimitri-yatsenko 於 5 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 70/100
datajoint/datajoint-python#1581 ·
維護者通常 4 天內回覆
-
dj.Diagram theme: make the font configurable可能已有人在做 @dimitri-yatsenko 於 4 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
datajoint/datajoint-python#1539 · 3 則留言 ·
維護者通常 4 天內回覆
-
bug
難度 4/5 1-2 天 新手友好度 68/100
datajoint/datajoint-python#1641 ·
維護者通常 4 天內回覆
-
A join on namesake secondary attributes raises the stale-`~lineage` error on a freshly declared schema可能已有人在做 @dimitri-yatsenko 於 4 天前認領。 未關閉bug
難度 3/5 1-2 天 新手友好度 82/100
datajoint/datajoint-python#1640 · 1 則留言 ·
維護者通常 4 天內回覆
-
PostgreSQL: renaming an attribute of a dj.U restriction quotes it with backticks可能已有人在做 @mayuriphad 於 4 天前認領。 未關閉bug
難度 3/5 1-2 天 新手友好度 75/100
datajoint/datajoint-python#1638 ·
維護者通常 4 天內回覆
查看 datajoint/datajoint-python 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
CLIMADA-project/climada_python#1337 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
8go/matrix-commander#233 ·
-
documentation
難度 2/5 1-3 小時 新手友好度 66/100
-
documentation enhancement priority:high size:M
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
Validate non-divisible effective batch sizes in the Unsloth LoRA backend可能已有人在做 @debesh-biswas 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 70/100