A commit's dependents step is lost when the worker dies before it or the step fails

オープン
#1,972 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
clickhouse, python
領域
backend, databases

調査の方向性

Start with pass_commit.py around _ingest_commit, _ingest_commit_files, and _resolve_dependents, then trace how pass_stream.py advances git_head and saves commit_slice. Read the related issue #1680 and PR #1967 for the existing dependents_pending approach. Reproduce the worker-death, failed-step, and multi-round cases described here; done means dependents are resolved after recovery and a failed step does not let the watermark advance past unfinished work.

索引モデルが issue の本文から書いたものです。

説明

Company

Independent

Component

Code index

Describe what's wrong

A commit's ingest (pass_commit._ingest_commit) writes the commit's files in rounds, then runs the dependents step (_resolve_dependents: closure repair of declined sites and the edges-only re-extraction of the untouched callers) over a delta built from the files' FileIngestStats, and only then does CommitStream.step move the git_head watermark (pass_stream.py). The delta lives only in memory, and the step can be lost in two ways.

  1. A worker that dies between the writes and the step. The watermark has not moved, so the next pass reruns the commit. But the commit's rows are already written, so the rerun's ingest_file compares the file against itself and reports no added or removed names and no retired ids. The rerun's delta is empty, _resolve_dependents returns without running, and the watermark moves. A caller in an untouched file whose declined site names a definition the commit added stays declined, and an edge into a definition the commit removed stays live, until a later commit touches the calling file. A commit ingested in more than one round has a second form of it: _ingest_commit_files saves the slice cursor (commit_slice) after each round is flushed, before the step, so a kill at the step resumes past the files the cursor counts, and the step never reads their change. With code_ingest_round_files = 1 and a commit touching two files, the cursor read <first>..<head>:1 at the step, and the resumed pass ingested only the second file and bound nothing.
  2. A step that fails. _resolve_dependents records the error and returns ("never fatal to the commit"), _ingest_commit returns as if the commit landed whole, and the watermark moves. Nothing runs the step again.

Neither path leaves anything stale for the reconcile to find: the touched files' blobs match their rows, and the callers' blobs did not move.

Does it reproduce on the latest release or main?

Yes, on main at 5bcab2dfa, with an integration probe against a private ClickHouse, a real git repository and the real _ingest_commit, ingest_file and dependents step.

How to reproduce
  1. Index src/lib.cpp (namespace DB { int other(); }) and src/caller0.cpp (int run0() { return helper(); }) at a first commit, so the caller's helper site is declined unresolved.
  2. Commit src/lib.cpp with int helper() added; src/caller0.cpp is untouched.
  3. Control: one _ingest_commit of that commit binds the caller's site (closure repair resolves 1, one edge into DB::helper, no declined site).
  4. Kill: in a fresh namespace, run _ingest_commit with _resolve_dependents raising a BaseException (a kill no handler catches). DB::helper is durable and the caller's site is still declined. Run _ingest_commit for the same commit again, as the next pass does: it returns None (the commit landed whole, so the watermark moves), closure repair resolves 0, and the caller keeps its declined helper site with no edge.
  5. Failed step: in a fresh namespace, run _ingest_commit with dependents.run_for_commit raising. It returns None with dependents: RuntimeError in the errors, and the caller keeps its declined site with no edge.
  6. Rounds: in a fresh namespace, set code_ingest_round_files = 1 and make the commit touch src/lib.cpp and a second file, src/zz.cpp. Drive CommitStream.step with _resolve_dependents raising a BaseException. At the step commit_slice already reads <first>..<head>:1. Step again, as the next pass does: it plans 1 file (it skips src/lib.cpp), closure repair resolves 0, the caller keeps its declined site, and git_head moves.
Expected behavior

A commit's dependents step runs once its files are written, whether the worker that wrote them survives or the first attempt fails: the callers end up bound to what the commit added and released from what it removed, as they are after a clean pass.

Environment

main, code index fast tier, commit walk.

Related issues and pull requests

Related: https://github.com/ClickHouse/loom/issues/1680, https://github.com/ClickHouse/loom/pull/1967

How this was found

An AI tool helped find it, and I reproduced it myself

Additional context

#1967 closes the same window for the reconcile and for loom code reconcile --heal: before each writer it records the paths' symbols in the dependents_pending row, and the step takes its delta from the rows against that record and clears it after it runs. The commit path differs in shape, so it was left out of that PR: a commit's delta spans rounds, slices and passes, its overflow is queued per commit, and a record would have to move with the slice cursor and the watermark. Recording each round's paths before it writes, and running the step from the record, is one shape; the per-round save of the slice cursor is what moves first today, so the record has to outlive it as well as the watermark. Keeping the record when the step fails, rather than moving the watermark past it, closes the second gap.

Redaction
  • I removed tokens, keys, passwords and personal or customer data from everything above.
主要言語
Python
スター
221
フォーク
35
平均マージ
14時間 21分
マージ済み PR(30日)
873

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ClickHouse/loom のほかの issue

ClickHouse/loom の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。