Unity-Technologies / Unity-Technologies/UnityDataTools

Handler Finalize() methods are never called, so intended indexes are never created

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

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

主要言語
C#
スター
821
フォーク
71
平均マージ
3時間 13分
マージ済み PR(30日)
9

説明

Summary

The ISQLiteHandler implementations each define a public void Finalize(SqliteConnection db) method, but nothing ever calls it. Finalize is not part of the ISQLiteHandler interface (which only declares Init, Process, and Dispose), and there is no dispatch site anywhere in the codebase. As a result, the finalization work in those methods never runs.

For most handlers the method is an empty stub, but two of them create indexes that are therefore never created:

  • AssetBundleHandler.Finalize -> preload_dependencies_object, preload_dependencies_dependency
  • ShaderHandler.Finalize -> shader_subprograms_shader_index, shader_subprogram_keywords_subprogram_id_index

(Note: SQLiteWriter.End() runs Resources.Finalize / Finalize.sql, which creates the refs indexes. That is a separate, top-level mechanism and does run - it is unrelated to these per-handler Finalize methods.)

Impact

  • The four indexes above are missing from every analyze database, so queries that filter/join on preload_dependencies(object), preload_dependencies(dependency), shader_subprograms(shader), and shader_subprogram_keywords(subprogram_id) do full scans. This is a performance issue only; results are still correct.
  • The empty Finalize stubs in the other handlers are dead code and misleadingly imply a finalization step exists.

Evidence

After running analyze on TestCommon/Data/LeadingEdgeBuilds/AssetBundles:

sqlite> SELECT name FROM sqlite_master WHERE type='index' AND name LIKE 'preload_%';
-- (no rows)

The preload_dependencies table and its data are present, but the indexes are not.

Affected files

  • Analyzer/SQLite/Handlers/ISQLiteHandler.cs - interface has no Finalize.
  • Non-empty bodies: Analyzer/SQLite/Handlers/AssetBundleHandler.cs, Analyzer/SQLite/Handlers/ShaderHandler.cs.
  • Empty stubs: AnimationClipHandler.cs, AudioClipHandler.cs, BuildReportHandler.cs, MeshHandler.cs, MonoScriptHandler.cs, PackedAssetsHandler.cs, PreloadDataHandler.cs, Texture2DHandler.cs.

Suggested fix

Either:

  1. Wire it up - add Finalize(SqliteConnection db) to ISQLiteHandler and invoke it once per handler after all serialized files are processed (the handler lifecycle is owned by SerializedFileSQLiteWriter; SQLiteWriter.End() is the natural point at which finalization runs). Drop the now-redundant empty overrides where possible. This restores the four intended indexes.

  2. Delete the dead code - if the indexes are not wanted, remove all the Finalize methods.

Option 1 is preferred since the indexes are clearly intended and benefit lookups on the dependency and shader-subprogram tables.

Notes

The two preload_dependencies_* index names were just updated in #82 (table rename); this bug predates that change - the indexes were never created under their old asset_dependencies_* names either.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

調査の方向性

Analyzer/SQLite/Handlers/ISQLiteHandler.cs と SerializedFileSQLiteWriter におけるハンドラーのライフサイクルから始め、SQLiteWriter.End() を提案されているファイナライズのエントリーポイントとして調査します。ハンドラーがどのように処理されるかを追跡し、analyze データベースに意図された 4 つのインデックスが現れること、また古い空のスタブが一貫して処理されることを確認して、完了を検証します。

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

評価

技術スタック
csharp, sqlite
領域
databases
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

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

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