feat: Optimize PG source_kind, relation deletion using indices - BED-8832#101
feat: Optimize PG source_kind, relation deletion using indices - BED-8832#101StephenHinck wants to merge 5 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdds PostgreSQL driver methods for deleting nodes and relationships by kind, updates kind-ID resolution, changes the node-edge delete trigger to statement-level cleanup, and adds integration tests for batch cascade behavior and both delete-by-kind paths. ChangesPostgreSQL Bulk Delete by Kind
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@drivers/pg/driver.go`:
- Around line 231-254: The delete builder in the `Delete` flow is too tolerant
when resolving `excludeAny`, which can turn a protected delete into an unguarded
`delete from node`. Update the logic around `resolveKindIDs` in
`drivers/pg/driver.go` so unresolved exclude kinds fail closed instead of being
silently dropped, and make the `predicates`/`arguments` construction in the
delete statement require valid `excludeIDs` before adding the `not (kind_ids
operator ...)` clause. Keep `includeAny` behavior unchanged, but ensure
`excludeAny` cannot widen the delete when `resolveKindIDs` returns an empty or
partial match.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0dd1938a-2de7-4984-b84d-79a28b13ad41
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (6)
drivers/pg/driver.godrivers/pg/query/sql/schema_up.sqlgo.modintegration/pgsql_delete_by_kind_test.gointegration/pgsql_delete_cascade_test.gointegration/pgsql_delete_relationships_by_kind_test.go
Description
Introduces new, optional functions for deleting nodes and relationships by kind, enabling the use of indices for more performant bulk deletes. This primarily supports the various database management capabilities built into BloodHound, but may be used for other bulk delete operations as necessary.
Implemented in
Resolves: BED-8832
Type of Change
Testing
make test_allwithCONNECTION_STRINGset)Screenshots (if appropriate):
Driver Impact
drivers/pg)drivers/neo4j)Checklist
go.mod/go.sumare up to date if dependencies changedSummary by CodeRabbit