Skip to content

Delete the chunks of a recursive delete's descendants, sweep those left behind, and check rebuilds against the database - #38884

Open
manerow wants to merge 8 commits into
fix/vector-chunk-lifecyclefrom
fix/vector-chunk-cascade-delete
Open

manerow wants to merge 8 commits into
fix/vector-chunk-lifecyclefrom
fix/vector-chunk-cascade-delete

Conversation

@manerow

@manerow manerow commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What

Stacked on PR #38841. Follows PR #38415.

  1. Hard delete. The vector handler deletes chunks in the prepareHardDelete hook, which every hard-deleted entity passes through, descendants of a recursive delete included, a type's entities together. After the commit, the chunks are deleted on the ordered lanes, one task per lane, behind updates already queued: one _mget and two bulks. A chunk set still stored goes to the search retry queue. The delete event no longer deletes chunks. A logical test suite's hard delete, which skipped the hook, now calls it.
  2. Soft delete. A recursive soft delete marks descendants deleted with no soft-delete event, so their chunks stayed matchable. The handler now deletes the chunks of any entity updated to deleted; a restore writes them back.
  3. Existing data. After the heal from PR Vector chunk deletes trust the header bound and fail when it cannot be read #38841, its runner sweeps once the chunks of entities the database no longer holds live, and records _meta.chunksOfDeletedEntitiesRemoved.
  4. Rebuilds. Before a full rebuild's chunk generation goes live, the same sweep checks it against the database and removes the chunks of entities deleted since the run read them, also those a server deleted only from the live index or failed to delete from the generation. A generation starts without the sweep's record, so going live runs the leased sweep again, for a delete between check and swap. This removes the 16 s wait before a run reads and the missed-delete flag with its partition and job plumbing.

Why

descendantsCoveredByAncestorCascade skips each descendant's delete event, and child documents are deleted by ancestor id, which chunks do not carry. So after a service, database or schema was deleted, semantic search and AskCollate kept returning its tables: on main for both engines, on OpenSearch since 2.0.

Decision record

ADR:2026-11-20-elasticsearch-and-opensearch-share-one-vector-index-service, v8, and ADR:2026-11-09-lifecycle-handlers-prepare-a-hard-delete-before-its-rows-are-removed, v2.

Verification

Local E2E (MySQL, stub embedder, counting proxy), main then this branch, same on Elasticsearch 9.3 and OpenSearch 3.4:

Scenario main this PR
Hard delete of a database service, 23 descendants, after 60 s 43 chunks left 0
Soft delete of a database service (10) and a dashboard service (12) all matchable none; restore brings all back
Hard delete of a schema with 500 tables 1000 chunks left 0, with 44 chunk requests (15 _mget, 29 bulks)
First start of this branch on main's data 523 deleted entities swept; 22 live kept
  • VectorChunkIndexIT, 34/34 on both engines. The descendant scenarios fail on PR Vector chunk deletes trust the header bound and fail when it cannot be read #38841's head; the two rebuild scenarios (a delete from a server whose lookup found no generation; a delete that failed in it) fail before item 4.
  • Unit: 4152 of 4153 search, lifecycle and reindex job tests pass (JobRecoveryOrphanDetectionTest fails without this PR too); the four new promotion tests fail before item 4.

Pending: an E2E of item 4 (the table covers items 1 to 3), the full impacted plan, and a multi-node run.

@manerow
manerow requested a review from a team as a code owner November 26, 2026 15:59
@manerow
manerow requested review from IceS2 and removed request for a team November 26, 2026 15:59
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@manerow manerow changed the title Delete the chunks of a recursive delete's descendants and sweep those left behind Delete the chunks of a recursive delete's descendants, sweep those left behind, and check rebuilds against the database Nov 27, 2026
@gitar-bot

gitar-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk

Cascade deletes and leased sweeps remove chunk sets from shared indexes; coordination or liveness races could erase live entities’ search content.

Deletes vector chunks for descendants of a recursive delete via the prepareHardDelete hook on ordered lanes, handles soft deletes and restores, and adds a sweep for chunks of entities no longer in the database. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants