-
Notifications
You must be signed in to change notification settings - Fork 9
fix: clamp max_age metrics at 0 #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
c4546d6 to
ff49283
Compare
ff49283 to
95acf79
Compare
95acf79 to
aebb0b0
Compare
1be44a8 to
01bd727
Compare
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
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
| "TIMEZONE('UTC', NOW())" | ||
| "TIMEZONE('UTC', STATEMENT_TIMESTAMP())" | ||
| when 'MySQL', 'Mysql2' | ||
| "UTC_TIMESTAMP()" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the behavior of mysql here? is it not impacted by the transaction start timestamp behavior on that platform?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
effron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
domainLGTM
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