Repository navigation
fix(jobs): record completed_time at millisecond precision (2.3) - #1614
Merged
dimitri-yatsenko merged 1 commit intoOct 21, 2026
Merged
Conversation
complete() and error() took completed_time from SELECT CURRENT_TIMESTAMP, which on MySQL has no fractional seconds, while reserve() writes reserved_time as CURRENT_TIMESTAMP(3) into the same datetime(3) columns. A job that finished within the second it was reserved recorded a completed_time earlier than its reserved_time. Error records carry no duration, so that difference is the only record of how long a failed job ran, and it came out negative or up to a second short. Both now read SELECT CURRENT_TIMESTAMP(3), as reserve() does. populate() calls them after the make() transaction has been committed or cancelled, and the PostgreSQL connection runs in autocommit mode, so there the value is the time of the statement, not the start of an enclosing transaction. The tests populate three keys through a make() that sleeps 0.15 s, once succeeding with keep_completed=True and once raising, and check that every job's completed_time is at least 0.1 s after its reserved_time, on MySQL and PostgreSQL. Both fail on MySQL without the change. Closes #1600. (cherry picked from commit d47ca3b)
dimitri-yatsenko
requested review from
MilagrosMarin,
lum-agilyti and
ttngu207
October 17, 2026 22:26
Member
Author
|
Merging on the strength of #1613's review: this is the same commit, cherry-picked to |
MilagrosMarin
approved these changes
Oct 21, 2026
MilagrosMarin
left a comment
Contributor
There was a problem hiding this comment.
LGTM. The diff matches #1613 line for line, the *_by_backend fixtures the new tests use are on maint/2.3, and CI is green.
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.
Backport of #1613 to
maint/2.3for v2.3.5, cherry-picked unchanged.complete() and error() took completed_time from SELECT CURRENT_TIMESTAMP,
which on MySQL has no fractional seconds, while reserve() writes
reserved_time as CURRENT_TIMESTAMP(3) into the same datetime(3) columns.
A job that finished within the second it was reserved recorded a
completed_time earlier than its reserved_time. Error records carry no
duration, so that difference is the only record of how long a failed job
ran, and it came out negative or up to a second short.
Both now read SELECT CURRENT_TIMESTAMP(3), as reserve() does. populate()
calls them after the make() transaction has been committed or cancelled,
and the PostgreSQL connection runs in autocommit mode, so there the value
is the time of the statement, not the start of an enclosing transaction.
The tests populate three keys through a make() that sleeps 0.15 s, once
succeeding with keep_completed=True and once raising, and check that every
job's completed_time is at least 0.1 s after its reserved_time, on MySQL
and PostgreSQL. Both fail on MySQL without the change.
Fixes #1600.