Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bowenlan-amzn opened this issue Feb 29, 2024 · 2 comments
Labels
bug Something isn't working untriaged

Comments

@bowenlan-amzn
Copy link
Member

Regarding this part of the logic for handling change policy

/*
* Try to update the ManagedIndexMetaData in cluster state, we need to do this first before updating the
* ManagedIndexConfig because if this fails we can fail early and still retry this whole process on the next
* execution whereas if we do the update to ManagedIndexConfig first we lose the ChangePolicy on the job and
* could fail to update the ManagedIndexMetaData which would put us in a bad state
* */
val updated = updateManagedIndexMetaData(updatedManagedIndexMetaData)
if (!updated.metadataSaved || policy == null) return
// Change the policy and user stored on the job from changePolicy, this will also set the changePolicy to null on the job
savePolicyToManagedIndexConfig(managedIndexConfig, policy.copy(user = changePolicy.user))

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

if (managedIndexMetaData.hasVersionConflict(managedIndexConfig)) {
val info = mapOf("message" to "There is a version conflict between your previous execution and your managed index")

@bowenlan-amzn bowenlan-amzn added bug Something isn't working untriaged labels Feb 29, 2024
@vikasvb90
Copy link
Collaborator

vikasvb90 commented Feb 29, 2024

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
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged
Projects
None yet
Development

No branches or pull requests

2 participants