-
Notifications
You must be signed in to change notification settings - Fork 516
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
Reindexes rest of batch if one resource fails #2118
Conversation
DECLARE @resourcesNotInDatabase int | ||
SET @resourcesNotInDatabase = (SELECT COUNT(*) FROM @computedValues WHERE ResourceSurrogateId IS NULL) | ||
|
||
IF (@resourcesNotInDatabase > 0) BEGIN | ||
-- We can't reindex resources that do not exist | ||
DELETE FROM @computedValues | ||
WHERE ResourceSurrogateId IS NULL | ||
END | ||
|
||
DECLARE @versionDiff int | ||
SET @versionDiff = (SELECT COUNT(*) FROM @computedValues WHERE VersionProvided IS NOT NULL AND VersionProvided <> VersionInDatabase) | ||
|
||
IF (@versionDiff > 0) BEGIN | ||
-- Don't reindex resources that have outdated versions | ||
DELETE FROM @computedValues | ||
WHERE VersionProvided IS NOT NULL AND VersionProvided <> VersionInDatabase | ||
END |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of throwing exceptions here, we simply remove the resources from @computedValues
, the table of resources to be reindexed.
// TODO: Return total number of successfully reindexed resources. | ||
int numberOfDeletedResources = sqlDataReader.GetInt32(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBD in AB#83909.
This pull request introduces 1 alert when merging 5d8b004 into 2f0d55d - view on LGTM.com new alerts:
|
var issue = new OperationOutcomeIssue( | ||
OperationOutcomeConstants.IssueSeverity.Error, | ||
OperationOutcomeConstants.IssueType.Exception, | ||
ex.Message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I am currently using this to pass an action item to the user on PreconditionFailed
exceptions, but I can see how this might lead to us sending info to the user that wouldn't be helpful. Working on finding a nice fix now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an extra catch block in 52ea697.
src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/CosmosFhirDataStore.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirDataStore.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirDataStore.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/CosmosFhirDataStore.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/azp run |
Pull request contains merge conflicts. |
-- @tokenNumberNumberCompositeSearchParams | ||
-- * Extracted token$number$number search params | ||
-- | ||
CREATE OR ALTER PROCEDURE dbo.ReindexResource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask why it doesn't upgrade version?
Description
Prior to this PR, when one resource failed to reindex due to a versioning conflict, the entire batch would fail.
Now, the remaining resources in the batch are reindexed. The query will be retried, fetching the most recent version of the failed resource from the database. In the rare scenario where all consecutive retry attempts fail, the reindexing operation will fail with the following error message:
Related issues
Addresses AB#79925
Testing
Next steps
When one or more resources in a batch initially fail to reindex but succeed on later attempts, the reindex job progress does not pick up the resources that succeeded on the first attempt. I created AB#83909 to track this.
FHIR Team Checklist
Semver Change (docs)
Patch (new schema version)