Skip to content

Use PIT + search_after for delete in serverless mode (#691) - #693

Merged
harshavamsi merged 3 commits into
opensearch-project:mainfrom
lawofcycles:fix/serverless-delete-search-after
Feb 20, 2026
Merged

Use PIT + search_after for delete in serverless mode (#691)#693
harshavamsi merged 3 commits into
opensearch-project:mainfrom
lawofcycles:fix/serverless-delete-search-after

Conversation

@lawofcycles

Copy link
Copy Markdown
Collaborator

Description

RestRepository.delete() uses the Scroll API to iterate all documents for bulk deletion, which is called when Spark's SaveMode.Overwrite is used. The Scroll API is not supported on OpenSearch Serverless, so overwrite operations fail when the existing document count exceeds the internal batch size (500).

With fewer than 500 documents, the overwrite happens to succeed because all documents are returned in the initial search response and no scroll continuation is needed. With more than 500 documents, the scroll continuation call (POST _search/scroll) returns 404.

This change branches the delete logic so that serverless mode uses PIT + search_after pagination (via scanLimitSearchAfter) to iterate all documents for deletion, consistent with the read path implemented in #586.

Verified on EMR 7.12 + OpenSearch Serverless with 600 documents (exceeding the 500 batch size).

Issues Resolved

Fixes #691

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…ect#691)

Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
@lawofcycles
lawofcycles force-pushed the fix/serverless-delete-search-after branch from 9060ca7 to ba7c996 Compare February 20, 2026 19:01
Signed-off-by: Sotaro Hikita <bering1814@gmail.com>
@lawofcycles

Copy link
Copy Markdown
Collaborator Author

Note: The Gradle Precommit CI job is expected to fail due to a dependency license SHA mismatch, which is unrelated to this PR and will be resolved by #688.

Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
@harshavamsi
harshavamsi merged commit 1422b67 into opensearch-project:main Feb 20, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Serverless mode: SaveMode.Overwrite fails when document count exceeds scroll size

2 participants