Skip to content

make db inquiry sequencially - #683

Merged
rhaegar325 merged 1 commit into
mainfrom
fix_db_test_precision_issue
Sep 1, 2026
Merged

make db inquiry sequencially#683
rhaegar325 merged 1 commit into
mainfrom
fix_db_test_precision_issue

Conversation

@rhaegar325

@rhaegar325 rhaegar325 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Order the legacy monitor_requests table by variable name instead of by
requested_at, so the monitor's merged request queue no longer depends on which
second each request landed in.

Changes

TaskTracker.take_monitor_requeststracking.py

- "ORDER BY requested_at, variable",
+ "ORDER BY variable",

requested_at defaults to CURRENT_TIMESTAMP, which resolves to whole seconds.
Requests enqueued in the same second therefore tied and fell back to the variable
name, and only requests that happened to straddle a second boundary came back in
arrival order — so the ordering could not deliver the arrival order it looks like
it delivers, and test_monitor_requests_are_taken_once failed under load when the
enqueues straddled a tick.

Variable-name order is also what the file queue this table is the legacy half of
already does: task_status.take_monitor_requests reads its requests in filename
order. The monitor concatenates the two, so ordering them the same way is what
makes the merged queue's submission order predictable. The requested_at column
is kept for diagnostics.

New regression testtests/unit/test_tracking.py

test_monitor_requests_order_does_not_depend_on_the_clock writes the two
timestamps a second apart directly rather than waiting for a boundary, so the
case that used to flake is now covered deterministically.

Impact

Only the order in which variables appended mid-run (moppy-cmorise --append-variables) are submitted as PBS jobs, and only for requests that
straddle a second boundary. Which variables run, and what they produce, are
unchanged. No schema change.

Verification

  • The new test fails without the ORDER BY change and passes with it.
  • The real flake reproducer (two enqueues either side of a sleep(1.1)) is now
    stable.
  • 2085 unit tests pass.

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.6%. Comparing base (c10597b) to head (ef27188).

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #683   +/-   ##
=====================================
  Coverage   78.6%   78.6%           
=====================================
  Files         41      41           
  Lines       8998    8998           
  Branches    1682    1682           
=====================================
  Hits        7073    7073           
  Misses      1591    1591           
  Partials     334     334           
Flag Coverage Δ
unit 78.6% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rhaegar325
rhaegar325 merged commit 649096a into main Sep 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant