Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #17732 +/- ##
============================================
+ Coverage 40.55% 40.56% +0.01%
- Complexity 2574 2575 +1
============================================
Files 5179 5179
Lines 349896 349918 +22
Branches 44727 44731 +4
============================================
+ Hits 141890 141954 +64
+ Misses 208006 207964 -42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
luoluoyuyu
left a comment
There was a problem hiding this comment.
Review 总结
整体方向正确:用引用计数修复「多 UDF 共享同一 jar 时 drop 一个误删 jar 元数据」的问题,rebuildJarMetadataFromUDFTable() 也能在 snapshot 恢复后重建一致性。UT 覆盖了共享 jar 与 snapshot 场景,质量不错。
建议在合入前处理下面 2 点(见行内评论),其中 MD5 一致性建议在 addJarReference 内防御性校验。
| } | ||
|
|
||
| private void addJarReference(String jarName, String jarMD5) { | ||
| existedJarToMD5.putIfAbsent(jarName, jarMD5); |
There was a problem hiding this comment.
putIfAbsent 只会在 jar 名已存在时保留第一次写入的 MD5,但仍会执行 merge 增加引用计数。
当前 validate() 在 addUDFInTable 之前会拦截「同名 jar、不同 MD5」,因此正常路径是安全的。但若未来有代码路径绕过 validate 直接调用 addJarReference,会出现 refCount 与 MD5 不一致。
建议:在 addJarReference 内增加防御性检查,例如:
final String existing = existedJarToMD5.get(jarName);
if (existing != null && !existing.equals(jarMD5)) {
throw new IoTDBRuntimeException(...);
}
existedJarToMD5.putIfAbsent(jarName, jarMD5);这样与 validate() 形成双保险。
| deserializeExistedJarToMD5(fileInputStream); | ||
|
|
||
| udfTable.deserializeUDFTable(fileInputStream); | ||
| rebuildJarMetadataFromUDFTable(); |
There was a problem hiding this comment.
processLoadSnapshot 先 deserializeExistedJarToMD5 再 rebuildJarMetadataFromUDFTable(),后者会 clear 并完全从 udfTable 重建 jar 元数据,使得反序列化的 existedJarToMD5 内容被丢弃。
若这是有意为之(以 udfTable 为唯一真相源),建议在方法上加一行注释说明,避免后续维护者误以为需要同时保留 snapshot 里的 jar map。
另:旧版本 snapshot 若 existedJarToMD5 与 udfTable 不一致,rebuild 能自动修复,这是加分项。



Description
This PR fixes UDF jar metadata handling in
UDFInfowhen multiple UDFs share the same jar.Background
UDFInfopreviously tracked uploaded jars only withjarName -> md5. When a UDF was dropped, the jar metadata wasremoved immediately. This breaks the case where multiple UDFs reference the same jar:
reappear after restart
Changes
This PR introduces reference counting for shared UDF jars in
UDFInfo.existedJarToReferenceCountto track how many UDFs are using each jarThis keeps shared jar metadata consistent across normal create/drop operations and snapshot recovery.
Tests
Updated
UDFInfoTestto cover the shared-jar cases:This PR has:
for an unfamiliar reader.
for code coverage.
Key changed/added classes (or packages if there are too many classes) in this PR