Repository navigation
fix(jobs): record completed_time at millisecond precision (2.3) - #1614
Open
dimitri-yatsenko wants to merge 1 commit into
Open
dimitri-yatsenko wants to merge 1 commit into
dimitri-yatsenko wants to merge 1 commit into
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
This branch has not been deployed
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.