Unity-Technologies / Unity-Technologies/UnityDataTools

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

Đang mở
#83 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
C#
Star
821
Fork
71
Merge trung bình
3 giờ 13 phút
Pull request đã merge (30 ngày)
9

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với Analyzer/SQLite/Handlers/ISQLiteHandler.cs và vòng đời của các handler trong SerializedFileSQLiteWriter; kiểm tra SQLiteWriter.End() như điểm vào được đề xuất cho việc hoàn tất. Theo dõi cách các handler được xử lý, sau đó xác minh việc hoàn tất bằng cách kiểm tra rằng bốn chỉ mục dự kiến xuất hiện trong cơ sở dữ liệu analyze và các stub trống đã lỗi thời được xử lý nhất quán.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, sqlite
Lĩnh vực
databases
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.