Conversation
After the change in #89 to have `delayed` surface DB-accurate max_age metrics, it appears that PostgreSQL will occasionally report a `run_at` that is milliseconds _after_ the current NOW() in UTC time. This is more than just clock drift between the DB and the server that inserted the row -- in READ COMMITTED mode, statements can see rows committed after the start of the transaction, while NOW() is frozen to the transaction start time. (Even without an explicit `BEGIN`, bare statements are wrapped in an implicit transaction.) This PR: - Switches PostgreSQL to `STATEMENT_TIMESTAMP()` to get even closer to the time at which the `SELECT` actually began. - Clamps at 0 anyways because clock drift is still a possibility. /no-platform stack-info: PR: #94, branch: smudge/stack/5
c22e230 to
c4546d6
Compare
8a56d8d to
8fd2fb0
Compare
This was referenced Feb 10, 2026
c4546d6 to
ff49283
Compare
Merged
ff49283 to
95acf79
Compare
95acf79 to
aebb0b0
Compare
1be44a8 to
01bd727
Compare
smudge
added a commit
that referenced
this pull request
Feb 10, 2026
After the change in #89 to have `delayed` surface DB-accurate max_age metrics, it appears that PostgreSQL will occasionally report a `run_at` that is milliseconds _after_ the current NOW() in UTC time. This is more than just clock drift between the DB and the server that inserted the row -- in READ COMMITTED mode, statements can see rows committed after the start of the transaction, while NOW() is frozen to the transaction start time. (Even without an explicit `BEGIN`, bare statements are wrapped in an implicit transaction.) This PR: - Switches PostgreSQL to `STATEMENT_TIMESTAMP()` to get even closer to the time at which the `SELECT` actually began. - Clamps at 0 anyways because clock drift is still a possibility. /no-platform stack-info: PR: #94, branch: smudge/stack/5
aebb0b0 to
16461fc
Compare
01bd727 to
65fa278
Compare
smudge
added a commit
that referenced
this pull request
Feb 10, 2026
After the change in #89 to have `delayed` surface DB-accurate max_age metrics, it appears that PostgreSQL will occasionally report a `run_at` that is milliseconds _after_ the current NOW() in UTC time. This is more than just clock drift between the DB and the server that inserted the row -- in READ COMMITTED mode, statements can see rows committed after the start of the transaction, while NOW() is frozen to the transaction start time. (Even without an explicit `BEGIN`, bare statements are wrapped in an implicit transaction.) This PR: - Switches PostgreSQL to `STATEMENT_TIMESTAMP()` to get even closer to the time at which the `SELECT` actually began. - Clamps at 0 anyways because clock drift is still a possibility. /no-platform stack-info: PR: #94, branch: smudge/stack/5
16461fc to
6d37d93
Compare
samandmoore
reviewed
Feb 11, 2026
| "TIMEZONE('UTC', NOW())" | ||
| "TIMEZONE('UTC', STATEMENT_TIMESTAMP())" | ||
| when 'MySQL', 'Mysql2' | ||
| "UTC_TIMESTAMP()" |
Member
There was a problem hiding this comment.
what's the behavior of mysql here? is it not impacted by the transaction start timestamp behavior on that platform?
Member
Author
There was a problem hiding this comment.
From what I can tell, MySQL's timestamp is equivalent to pg's statement timestamp -- as in, NOW() is based on statement time already, not transaction start.
6d37d93 to
7d7eaf4
Compare
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 PRs:
fix: clamp max_age metrics at 0
After the change in #89 to have
delayedsurface DB-accurate max_agemetrics, it appears that PostgreSQL will occasionally report a
run_atthat is milliseconds after the current NOW() in UTC time.
This is more than just clock drift between the DB and the server that
inserted the row -- in READ COMMITTED mode, statements can see rows
committed after the start of the transaction, while NOW() is frozen to
the transaction start time. (Even without an explicit
BEGIN, barestatements are wrapped in an implicit transaction.)
This PR:
STATEMENT_TIMESTAMP()to get even closer tothe time at which the
SELECTactually began./no-platform