Repository navigation
Conversation
devhawk
added this pull request to stack #614
October 8, 2026 21:08
…ated_at A DELAYED workflow was released when its delay_until_epoch_ms was at or before the clock of whichever JVM ran the release, which is often not the JVM that enqueued it. Every executor sharing a system database shares its clock, so the release now compares against the database's now(). Whichever executor runs the release, a delay ends at the same instant. The release also stamps updated_at, which it used to leave unchanged. The end of a relative delay is still resolved from the enqueuing JVM's clock, once, outside the write's retry loop. DelayReleaseClockTest shifts the database's clock an hour either way by shadowing now() and clock_timestamp() on the connections' search path, sets a delay to end a second from the database's now, and checks the workflow is released a second later with updated_at on the database's clock. On the JVM's clock it was never released with the database an hour ahead, and released at once with it an hour behind.
devhawk
force-pushed
the
delay-release-db-clock
branch
from
October 8, 2026 21:24
25fe0f5 to
100bc77
Compare
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation is consistent with existing database-time handling and is adequately tested.
0 open findings
What changed in this PR
Uses the shared database clock to release delayed workflows consistently across executors and stamp release time.
Changes:
- Compares delayed-workflow deadlines against database
now(). - Updates
updated_atwhen releasing workflows. - Adds PostgreSQL clock-skew coverage and updates clock documentation.
| File | Description |
|---|---|
DelayReleaseClockTest.java |
Tests release timing and timestamping under clock skew. |
SystemDatabase.java |
Documents database-clock use for delayed releases. |
WorkflowDAO.java |
Uses database time for delayed transitions and updated_at. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #612.
A DELAYED workflow was released when its
delay_until_epoch_mswas at or before the clock of whichever JVM ran the release. That is often not the JVM that enqueued it.transitionDelayedWorkflowsnow compares against the database'snow(), the one clock every executor sharing the system database shares, so whichever executor runs the release, a delay ends at the same instant.updated_at: the release also stamps it from the database's clock. The statement used to leave it unchanged.NOW_EPOCH_MSjavadoc now lists the release among the times kept on the database's clock.Tests
DelayReleaseClockTest(new, Postgres only):now()andclock_timestamp()on the connections'search_path;now();updated_aton the database's clock.The executor in the test doesn't dequeue the workflow's queue, so the released row stays ENQUEUED and keeps the release's own
updated_at. On the old statement the test fails both ways: with the database an hour ahead the workflow is never released, and with it an hour behind it is released at once.Run locally on Postgres:
spotlessCheck,compileTestJavaandjavadoc, plus:DelayReleaseClockTest,DatabaseClockTest,WorkflowTimeoutSweepTest,TimeoutTestandDebounceDelayedWorkflowTeston this branch;DebouncerTest,DebouncerClientTest,StartWorkflowTest,ClientTestandSystemDatabaseTestbefore it was stacked.🤖 Generated with Claude Code