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

Add support for partial delete success #3781

Merged
merged 4 commits into from
Apr 2, 2024

Conversation

LTA-Thinking
Copy link
Collaborator

@LTA-Thinking LTA-Thinking commented Mar 27, 2024

Description

If Cosmos DB runs out of RUs while performing a delete operation it will roll back the transaction. This can lead to a situation where it is impossible to delete a resource because it has too much history to delete in one pass. This PR add the ability to optionally support partial delete success. This allows for the service to delete as much of a resource as it can, and leave the rest for a later delete operation. By rerunning the delete operation eventually the resource will be deleted.

Related issues

Addresses AB#118312

Testing

Manually tested. Working on unit tests. E2E tests aren't possible as the scenario is hard to manufacture.

FHIR Team Checklist

  • Update the title of the PR to be succinct and less than 65 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
  • Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
  • Tag the PR with Schema Version backward compatible or Schema Version backward incompatible or Schema Version unchanged if this adds or updates Sql script which is/is not backward compatible with the code.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Patch

@LTA-Thinking LTA-Thinking added Bug Bug bug bug. Azure API for FHIR Label denotes that the issue or PR is relevant to the Azure API for FHIR labels Mar 27, 2024
@LTA-Thinking LTA-Thinking added this to the S137 milestone Mar 27, 2024
@LTA-Thinking LTA-Thinking requested a review from a team as a code owner March 27, 2024 20:17

namespace Microsoft.Health.Fhir.Core.Exceptions
{
public class PartialDeleteSuccessException : MicrosoftHealthException
Copy link
Member

@brendankowitz brendankowitz Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of an exception, I still prefer the terminology of "Incomplete" over "PartialSuccess" 🤔

I'd also argue this is a form of RequestTooCostlyException.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the name better, but I'm hesitant on Request Too Costly. We currently handle those with a 401, and I think 429 is the correct response for this. The request isn't bad, we just are unable to make it work in one pass.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched and changed it to use code 413, request too large.

public class PartialDeleteSuccessException : MicrosoftHealthException
{
public PartialDeleteSuccessException(int numberOfResourceVersionsDeleted)
: base(Resources.PartialDeleteSuccess.Replace("{0}", numberOfResourceVersionsDeleted.ToString(), StringComparison.Ordinal))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be using string.Format?

@LTA-Thinking LTA-Thinking merged commit 72cc6b5 into main Apr 2, 2024
43 checks passed
@LTA-Thinking LTA-Thinking deleted the personal/rojo/cosmos-partial-delete branch April 2, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure API for FHIR Label denotes that the issue or PR is relevant to the Azure API for FHIR Bug Bug bug bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants