wenzhenghu commented on PR #67750:
URL: https://github.com/apache/doris/pull/67750#issuecomment-5611033920

   **Agent:TRAE(TraeCode 主 Agent);所用大模型:GLM-5.3。**(迁移自内部镜像 PR 
HYDCP/hy-doris#103 的验证记录,该镜像基于 branch-3.1,与本 PR 补丁内容一致)
   
   ## 静态 Review + 测试结果
   
   ### 静态 Review:修复正确、对症
   
   **根因确认**:`eraseDatabase/eraseTable/erasePartition` 在 read lock 下仅快照过期 ID 
列表;释放读锁后、逐项获取 write lock 前,若对象被 recover 并以同一 ID 重新 recycle,后续 
`idToXxx.remove(id)` / `get(id)` 会误删**新一代**对象并写入 erase journal(ABA 竞态)。旧代码 
`dbInfo == null` 只防"已被 erase",不防"同 ID 换代"。
   
   **修复方案验证**:
   - `ExpiredCandidate<T>` 三元组快照(ID + `RecycleInfo` 引用 + recycleTime)在 read 
lock 下采集,字段完整;
   - `isSameGenerationAndExpired` 三重校验:`recycleInfoMap.get(id) == 
candidate.recycleInfo`(引用相等即同一代)、时间戳未变、以 sweep 固定的 `currentTimeMs` 
边界复查过期——三个条件与竞态窗口精确对应;
   - 校验失败 `continue` 跳过,不会误写 erase journal;
   - 三条 erase 路径(database/table/partition)统一走同一 helper;
   - 快照采集仍在 read lock 内,未改变原有锁纪律。
   
   ### 测试结果(内部镜像分支上执行)
   
   **FE UT**(`run-fe-ut.sh --run 
org.apache.doris.catalog.CatalogRecycleBinTest`):
   
   ```
   Tests run: 33, Failures: 0, Errors: 0, Skipped: 0
   ```
   
   surefire 报告确认 3 个新增 ABA 测试全部执行并通过:
   - `testExpiredDatabaseSnapshotDoesNotEraseNewGeneration`
   - `testExpiredTableSnapshotDoesNotEraseNewGeneration`
   - `testExpiredPartitionSnapshotDoesNotEraseNewGeneration`
   
   测试通过注入自定义 `ReentrantReadWriteLock`,在 erase 线程释放快照读锁的瞬间挂起、完成"恢复+重新回收同 
ID"换代、再放行 erase——精确复现竞态窗口,确定性高(latch 控制,不依赖时序),三个断言(仍在回收站、recycleTime 
为新的正值)正确覆盖修复语义。
   
   **回归测试**(双 FE 滚动升级至含本 PR 的 jar 后执行):
   
   | 套件 | 结果 |
   |---|---|
   | `catalog_recycle_bin_p0` 全目录(recover / recover_with_schema_change / show / 
test_drop_catalog_recycle_bin / test_insert_overwrite_recover / 
test_insert_overwrite_recover_no_partition) | ✅ 6 suites, failed 0 |
   
   升级前基线同样执行一遍 6/6 通过,升级前后无差异。
   
   ### 结论
   
   **LGTM**。修复了真实的 ABA 竞态(触发条件:回收站对象在过期扫描后被恢复并再次回收,同 ID 换代),修复方案严谨、测试覆盖完整(3 
个确定性竞态复现测试 + 全量回归通过),建议合入。
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to