Skip to content

Conversation

@jestradaMS
Copy link
Contributor

@jestradaMS jestradaMS commented Oct 30, 2025

Description

This pull request introduces significant improvements to logging, error handling, and performance instrumentation in the reindex job orchestration and processing workflow. The changes provide detailed timing and progress information for each stage of the reindex process, enhance cancellation and exception handling, and optimize resource processing through parallelization. These updates will make it easier to monitor, debug, and optimize reindex jobs.

Logging and Performance Instrumentation:

  • Added detailed timing and progress logs throughout the reindex processing workflow, including validation, search queries, resource extraction, batch updates, and overall job execution in ReindexProcessingJob.cs. Each major step now records elapsed time and throughput metrics for better observability. [1] [2] [3] [4] [5] [6] [7]
  • Instrumented the orchestrator job to log more specific cancellation reasons and errors, distinguishing between caller-requested cancellations and timeouts, and providing improved error context in logs.

Error and Cancellation Handling:

  • Improved handling of OperationCanceledException in both orchestrator and processing jobs, ensuring logs accurately reflect whether cancellation was due to a caller request or a timeout, and added additional error logging for unexpected exceptions. [1] [2] [3] [4]

Performance Optimization:

  • Refactored resource extraction in ProcessSearchResultsAsync to use parallel processing with ConcurrentBag, leveraging all available CPU cores for faster search parameter extraction and batch preparation. Added detailed logging for extraction and batch update timings. [1] [2]

Minor Improvements:

  • Added KnownQueryParameterNames.IgnoreSearchParamHash to the set of query hint parameter names in SearchOptionsFactory.cs, potentially enabling new query behaviors.

Related issues

Addresses AB#175355.

Testing

<style> </style>
GroupId TotalProcessingJobs CompletedJobs FailedJobs AvgDurationMilliseconds AvgDurationSeconds MinDurationMilliseconds MaxDurationMilliseconds TotalProcessingTimeSeconds JobConfiguration
3608 3 3 0 4790 4 2716 6247 14 2 workers w/2500 resources per job
3604 3 3 0 3623 3 3420 3754 10 2 workers w/2500 resources per job
3600 3 3 0 5247 5 2656 8414 15 2 workers w/2500 resources per job
3596 3 3 0 7972 7 6997 8887 23 2 workers w/2500 resources per job - OLD CODE
3592 3 3 0 8224 8 5933 9520 24 2 workers w/2500 resources per job - OLD CODE
3588 3 3 0 10062 10 5267 16940 30 2 workers w/2500 resources per job - OLD CODE
3584 3 3 0 39289 39 5760 102540 117 2 workers w/2500 resources per job - OLD CODE

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.
  • When changing or adding behavior, if your code modifies the system design or changes design assumptions, please create and include an ADR.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Patch|Skip|Feature|Breaking (reason)

Added Performance  logging in ReindexProcessingJob
Added parallel processing of resources in ReindexProcessingJob increasing runtimes 2x per job
Added IgnoreSearchParamHash to queryHintParameterNames collection in SearchOptionsFactory to prevent error during reindexing queries
@jestradaMS jestradaMS added this to the CY25Q4/2Wk02 milestone Oct 30, 2025
@jestradaMS jestradaMS requested a review from a team as a code owner October 30, 2025 18:11
@jestradaMS jestradaMS added Enhancement-Optimization Optimization on existing functionality. Azure API for FHIR Label denotes that the issue or PR is relevant to the Azure API for FHIR 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 Oct 30, 2025
PTaladay
PTaladay previously approved these changes Oct 30, 2025
… counters

Fixing logging in ReindexProcessingJob

private async Task<SearchResult> GetResourcesToReindexAsync(SearchResultReindex searchResultReindex, CancellationToken cancellationToken)
{
var stopwatch = Stopwatch.StartNew();
Copy link
Contributor

Choose a reason for hiding this comment

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

My problem with detailed time logging is thar it makes a lot of clutter and makes main code not readable.

entry.Resource.SearchParameterHash = searchParamHash;
_resourceWrapperFactory.Update(entry.Resource);
updateSearchIndices.Add(entry.Resource);
// Parallel processing of search parameter extraction
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed offline, we should not do this.

Copy link
Contributor

@SergeyGaluzo SergeyGaluzo left a comment

Choose a reason for hiding this comment

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

please address my comments.

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 Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Enhancement-Optimization Optimization on existing functionality. Schema Version unchanged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants