Skip to content

Time the lost-lease schema cache by the framework clock - #1250

Merged
rmcdaniel merged 1 commit into
mainfrom
general/lost-lease-schema-cache-clock
Nov 20, 2026
Merged

rmcdaniel merged 1 commit into
mainfrom
general/lost-lease-schema-cache-clock

Conversation

@rmcdaniel

Copy link
Copy Markdown
Member

Fixes a flaky test on main introduced by #1244: ChildClosureSiblingHistoryCostTest::testChildClosureQueryCountDoesNotGrowWithFanOut (coverage-unit) saw 159 queries against 157 expected.

Cause

WorkflowTaskLeaseLoss::hasColumn() cached its schema check for 60 s using PHP's time(). Tests freeze the framework clock but not time(), so on a slow run the 60 s window ran out mid-measurement and the schema check ran again.

Change

  • The cache window now uses Date::now()->getTimestamp(), so a frozen test clock holds it.
  • If the clock moves backwards, the check runs once more and then holds again.
  • This was the only time()-based cache added in 2.34.0. I checked every src file changed between 2.33.0 and 2.34.0.
  • A CHANGELOG entry is under Unreleased. A 2.34.1 is not needed for this.

Tests

  • New V2WorkflowTaskLostLeaseTest::testTheSchemaCheckWindowFollowsTheFrameworkClock. With a frozen clock, a 59 s travel issues no schema query and 60 s re-checks; a backwards travel re-checks once and then holds. It fails against the time() version ("0 is greater than 0") and passes with this change.
  • V2WorkflowTaskLostLeaseTest passes on SQLite and MySQL 8.4, and ChildClosureSiblingHistoryCostTest passes on SQLite.
  • ecs and phpstan are clean.

🤖 Generated with Claude Code

WorkflowTaskLeaseLoss cached its schema check for 60 s using PHP's time(),
which a frozen test clock does not hold. On slow runs the check repeated
mid-measurement and query-count tests saw extra queries. Use the Date
facade, and re-check once when the clock moves backwards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rmcdaniel rmcdaniel added the agent:general Work owned by General label Nov 20, 2026
@sonarqubecloud

Copy link
Copy Markdown

@rmcdaniel
rmcdaniel merged commit 18fc2ee into main Nov 20, 2026
47 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:general Work owned by General

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant