Skip to content

Use DB time for background job time limit#5560

Merged
LTA-Thinking merged 8 commits into
mainfrom
personal/rojo/use-db-time
May 29, 2026
Merged

Use DB time for background job time limit#5560
LTA-Thinking merged 8 commits into
mainfrom
personal/rojo/use-db-time

Conversation

@LTA-Thinking

Copy link
Copy Markdown
Contributor

Description

Some background jobs have a clause to prevent them working on data created after they were queued. This PR changes the source of the time to be the DB set create time instead of it being set by the server when the job is queued. This prevents mismatches between the two sources that could lead to resources being missed if they were created very soon before a job was enqueued.

Related issues

Addresses Bug 191061

Testing

Existing E2E tests

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)

@LTA-Thinking LTA-Thinking added this to the FY26\Q4\2Wk\2Wk23 milestone May 11, 2026
@LTA-Thinking LTA-Thinking requested a review from a team as a code owner May 11, 2026 20:21
@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 Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs No-PaaS-breaking-change No-ADR ADR not needed labels May 11, 2026
@codecov-commenter

codecov-commenter commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.32%. Comparing base (fdf6900) to head (eb823c1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5560      +/-   ##
==========================================
+ Coverage   77.28%   77.32%   +0.04%     
==========================================
  Files         995      996       +1     
  Lines       36467    36431      -36     
  Branches     5520     5518       -2     
==========================================
- Hits        28184    28172      -12     
+ Misses       6924     6904      -20     
+ Partials     1359     1355       -4     

see 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rbans96 rbans96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice fix ? using DB time eliminates the clock skew issue cleanly. The Task.Delay removals in E2E tests confirm it works. A couple things to consider:

@rbans96

rbans96 commented May 22, 2026

Copy link
Copy Markdown
Contributor

Potential Bug: Inconsistent DateTime → DateTimeOffset conversion

In BulkUpdateOrchestratorJob.cs around line 178:
csharp var createDate = new PartialDateTime(jobInfo.CreateDate);

But in CreateProcessingDefinition (same file, line ~279):
csharp var createDate = new PartialDateTime(new DateTimeOffset(jobCreateDate, TimeSpan.Zero));

JobInfo.CreateDate is DateTime (not DateTimeOffset). The first form relies on C#'s implicit conversion, which uses the local timezone offset when DateTime.Kind == Unspecified. The second form explicitly sets UTC offset. If the DB returns Kind == Unspecified, these two paths will produce different timestamps on non-UTC servers.

Suggest using
ew PartialDateTime(new DateTimeOffset(jobInfo.CreateDate, TimeSpan.Zero)) consistently in both places to avoid subtle timezone bugs.

@LTA-Thinking LTA-Thinking merged commit adf30d0 into main May 29, 2026
49 checks passed
@LTA-Thinking LTA-Thinking deleted the personal/rojo/use-db-time branch May 29, 2026 21:20
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 Bug Bug bug bug. No-ADR ADR not needed No-PaaS-breaking-change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants