Search param cache, Reindex: Replace blind wait by sync check#5432
Search param cache, Reindex: Replace blind wait by sync check#5432SergeyGaluzo wants to merge 9 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5432 +/- ##
=======================================
Coverage ? 76.93%
=======================================
Files ? 975
Lines ? 35547
Branches ? 5329
=======================================
Hits ? 27347
Misses ? 6875
Partials ? 1325 🚀 New features to boost your workflow:
|
| _operationsConfiguration.Reindex.CacheRefreshMaxWaitIntervals, | ||
| cancellationToken); | ||
| cacheLastUpdated = _searchParameterOperations.SearchParamLastUpdated.HasValue ? _searchParameterOperations.SearchParamLastUpdated.Value : DateTimeOffset.MinValue; | ||
| isBad = _reindexProcessingJobDefinition.SearchParamLastUpdated > cacheLastUpdated; |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
Generally, to fix a “useless assignment to local variable” you either (a) remove the assignment if its result is not needed, or (b) start using the variable in a meaningful way if the recomputed value is actually required. Here, the recomputation of isBad after the cache sync wait is not used anywhere, and the assignment has no side effects. The simplest, behavior-preserving fix is to remove that assignment line.
Concretely, in CheckSync in src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/ReindexProcessingJob.cs, remove the line:
isBad = _reindexProcessingJobDefinition.SearchParamLastUpdated > cacheLastUpdated;at line 155, and leave the subsequent recomputation of cacheLastUpdatedStr and logging logic unchanged. No new imports, methods, or other definitions are needed, since we’re only deleting an unused assignment.
| @@ -152,7 +152,6 @@ | ||
| _operationsConfiguration.Reindex.CacheRefreshMaxWaitIntervals, | ||
| cancellationToken); | ||
| cacheLastUpdated = _searchParameterOperations.SearchParamLastUpdated.HasValue ? _searchParameterOperations.SearchParamLastUpdated.Value : DateTimeOffset.MinValue; | ||
| isBad = _reindexProcessingJobDefinition.SearchParamLastUpdated > cacheLastUpdated; | ||
|
|
||
| cacheLastUpdatedStr = cacheLastUpdated.ToString(ReindexOrchestratorJob.LogDateTimeFormat); | ||
| if (isInSync) |
Replaces blind wait for 3 cache refresh intervals with check for sync with the database.