Skip to content

Reindex racing and incremental cache update fixes#5350

Merged
SergeyGaluzo merged 118 commits intomainfrom
users/sergal/reindexracing
Feb 12, 2026
Merged

Reindex racing and incremental cache update fixes#5350
SergeyGaluzo merged 118 commits intomainfrom
users/sergal/reindexracing

Conversation

@SergeyGaluzo
Copy link
Contributor

@SergeyGaluzo SergeyGaluzo commented Jan 23, 2026

Fixes the problem in the incremental search param cache update logic.

Before the fix:

  1. Get last updated from the database and compare it to internal property to check whether anything needs to be done.
  2. Get changed status records.
  3. Apply changes to internal dictionaries (i.e. cache). This includes running search by URIs.
  4. Get last updated from the database and update internal property.

Any transactions between #2 and #4 were not reflected in cache

After the fix:
In #4 code does not read the database but uses data point saved in #1.

Racing between search parameter create and cache refresh
Before the fix:

  1. New search parameter gets inserted in the SearchParam table, but not yet in the Resource table.
  2. Incremental update is invoked by incremental cache refresh logic. This advances internal property based on max in SearchParam.LastUpdated but is not able to add search param in cache as resource data is missing.
  3. Subsequent attempts to update cache silently skip, because search param are considered processed.
  4. Reindex processing jobs process data based on old search param definitions, no true reindexing, data is not searchable after success of reindex.

After the fix:
There is an additional check in 2 whether search param is added to cache. If not, SearchParam.LastUpdated internal property is not advanced.
Subsequent attempt to update cache succeeds.

Other fixes of racing bugs:
https://microsofthealth.visualstudio.com/Health/_workitems/edit/180950/
https://microsofthealth.visualstudio.com/Health/_workitems/edit/180898/

Removes ALL retries from e2e reindex tests, which were hiding the issues.

@SergeyGaluzo SergeyGaluzo added this to the CY25Q3/2Wk07 milestone Jan 23, 2026
@SergeyGaluzo SergeyGaluzo requested a review from a team as a code owner January 23, 2026 22:01
@SergeyGaluzo SergeyGaluzo added Bug Bug bug bug. Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Schema Version unchanged labels Jan 23, 2026
@microsoft microsoft deleted a comment from azure-pipelines bot Feb 9, 2026
@microsoft microsoft deleted a comment from azure-pipelines bot Feb 9, 2026
@microsoft microsoft deleted a comment from azure-pipelines bot Feb 9, 2026
@microsoft microsoft deleted a comment from azure-pipelines bot Feb 10, 2026
@microsoft microsoft deleted a comment from azure-pipelines bot Feb 10, 2026
feordin
feordin previously approved these changes Feb 10, 2026
@SergeyGaluzo SergeyGaluzo enabled auto-merge (squash) February 12, 2026 21:12
@SergeyGaluzo SergeyGaluzo merged commit 9a9709c into main Feb 12, 2026
60 of 61 checks passed
@SergeyGaluzo SergeyGaluzo deleted the users/sergal/reindexracing branch February 12, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Bug Bug bug bug. No-PaaS-breaking-change Schema Version backward compatible SQL Scripts If SQL scripts are added to the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants