Repository navigation
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
| removeChunksUnlessEmbedded(normalize(record.getEntityId()), root.getType(), rootEntity); | ||
| completeClaim(record); |
There was a problem hiding this comment.
⚠️ Edge Case: A failed chunk-delete replay still completes the retry claim
The retry worker is now the only place that replays a chunk delete shed by a full lane. It calls vectorService.deleteEntityChunks(entityId) and then completeClaim(record) without checking the outcome. On 2.1, OpenSearchVectorService.deleteEntityChunks goes through deleteChunksFrom, which catches every Exception and logs it at DEBUG. So if OpenSearch rejects or times out the delete (likely under the same load that filled the lane), nothing reaches handleProcessingError. The row is still deleted from the queue as a success, and the descendant's chunks stay matchable until a full reindex. The retry ends up dropping the exact work it exists to replay.
Fix: on the retry path, use a chunk delete that throws. For example, add a deleteEntityChunksOrThrow to VectorIndexService (the default can delegate) that rethrows instead of logging at DEBUG, and call it from removeChunksOf. The failure then goes through handleProcessingError and the claim is kept for another attempt.
Use a variant that throws on the retry path so the existing error handling keeps the claim:
private void removeChunksOf(String entityId, String entityType) throws IOException {
VectorIndexService vectorService = searchRepository.getVectorIndexService();
boolean embeddedType =
entityType.isEmpty() || AvailableEntityTypes.isVectorIndexable(entityType);
if (vectorService != null && embeddedType) {
vectorService.deleteEntityChunksOrThrow(entityId);
}
}
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
What
Backport of PR #38884 to 2.1, adapted rather than cherry-picked. 2.1 has neither the shared vector service of PR #38415 nor the chunk delete of PR #38841, and on 2.1 only OpenSearch has a chunk index. So this ports the lifecycle part and the retry worker's chunk cleanup; the vector handler keeps 2.1's own delete for each entity.
prepareHardDeletehook, which every hard-deleted entity passes through, descendants of a recursive delete included. The dispatcher gives a handler the entities of one type together, which a recursive delete prepares in groups of up to 500 per tree level. After each group's commit, its chunks are deleted on the ordered lanes, behind any update already queued, in at most one task per lane, not one per descendant. The delete event no longer deletes chunks. A logical test suite's hard delete, the one path that skipped the hook, now calls it.Apart from one javadoc, the lifecycle files match PR #38884. PR #38884 also batches deletes inside each lane task and sweeps orphaned chunks; this backport does neither (see the release note).
Why
After a service, database or schema was deleted, semantic search and AskCollate kept returning its tables, dashboards and charts. This affects OpenSearch on every 2.0 and 2.1 release.
Decision record
ADR:2026-11-09-lifecycle-handlers-prepare-a-hard-delete-before-its-rows-are-removed, v2, worded as in PR #38884. The chunk lifecycle record exists only on main.
Verification
VectorChunkCascadeDeleteIT(OpenSearch 3.4, calls the vector handler directly, no server): without this change, 40 tables passed through the hard delete hook keep their chunks after 30 s and a soft-deleted table keeps all 3; with it, both pass.SearchIndexRetryWorkerTestcases fail without the retry worker change and pass with it: gone, soft-deleted, opted-out and replaced entities lose their chunks, a live embedded one keeps them.Not run on 2.1: a local server E2E (run on main for both engines in PR #38884) and the full impacted plan.
Release note
On OpenSearch with semantic search, chunks left by earlier recursive deletes stay searchable until the next Search Indexing run that covers all entity types. If your scheduled run covers only some types, run it once with all entities after upgrading.