opensearch-project / index-management

🗃 Automate periodic data operations, such as deleting indices at a certain age or performing a rollover at a certain size
https://opensearch.org/docs/latest/im-plugin/index/
Apache License 2.0
52 stars 107 forks source link

[BUG] Update metadata and job documents in one run when handle change policy #1121

Closed bowenlan-amzn closed 4 months ago

bowenlan-amzn commented 4 months ago

Regarding this part of the logic for handling change policy

https://github.com/opensearch-project/index-management/blob/930157b7d5d22df48f2d48b07bf480f5aa3bf25c/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt#L784-L795

I feel it's possible to combine these 2 into one bulk call, so they always fail or succeed at same time.

If only metadata update succeed, it seems possible to fall into this check and stop running

https://github.com/opensearch-project/index-management/blob/930157b7d5d22df48f2d48b07bf480f5aa3bf25c/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt#L306-L307

vikasvb90 commented 4 months ago

Bulk doesn't guarantee atomic ingestion of all documents it carries. There can be partial failures. Looking at partial failures of the response will also not work because rollback (deletion) of ingested doc or ingestion of failed doc is again not guaranteed. The only possible solution of this which requires a major effort would be to maintain a parent-child relationship to designate a group of docs and accordingly modify search queries and subsequent updates.

bowenlan-amzn commented 4 months ago

Got it. Just note down another approach — moving metadata as a field into job document. The small downside is anything in job document change will trigger the listener from Job Scheduler to reschedule the job.