Repository navigation
fix(model): delete provider models and instances in one transaction - #19562
Conversation
DropProviderInstances runs two independent deletes on main: tenant models by instance IDs, then the instances themselves. If the instance delete fails, the tenant models are already gone, leaving a partially deleted provider. Review bots flagged the same non-transactional batch loop on infiniflow#14166 and infiniflow#16180. Wrap both deletes in a single gorm transaction and add a regression test that forces the instance delete to fail and asserts the rollback keeps the tenant models.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesProvider instance deletion
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The transactional deletion path and rollback regression coverage preserve provider data consistency when instance deletion fails. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit checks the rows with care Comment |
Summary
DropProviderInstances(modelDAO.DeleteByInstanceIDs+modelInstanceDAO.DeleteByIDs) in a single gorm transaction, so a failure of the instance delete can no longer leave the tenant models already removed (partial provider deletion)tenant_model_instancedelete to fail and asserts the rollback keeps the tenant modelsWhy
On current
mainthe two deletes run independently. If the second delete fails, the models of the dropped instances are already gone while the instances remain, leaving an inconsistent provider state. The same non-transactional batch loop was flagged by the review bot on #14166 and #16180.Tests
go test ./internal/service/ -run TestDropProviderInstances(new rollback case + existing model provider suites)