Give probe_result duration sub-second precision#96
Merged
Conversation
`t.decimal :duration` with no precision becomes DECIMAL(10,0) on MySQL, which rounds every value to a whole second on write. Probe durations are sub-second floats from a monotonic clock, so post-MySQL-migration they were all stored as 0 and rendered as 0.00s. SQLite preserved the fractional value, which is why this only surfaced after the migration. Alter the column to DECIMAL(10,6) (microsecond precision). Existing rows already rounded to 0 can't be recovered; new probe results record their true duration. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
After the SQLite → MySQL migration, the duration of most probe results renders as
0.00sin production.The
durationcolumn is declared ast.decimal :durationwith no precision (db/migrate/20250114000001_create_upright_probe_results.rb). Duration is computed from a monotonic clock and is almost always sub-second:On SQLite, NUMERIC affinity stored the full float (
0.043). On MySQL,DECIMALwith no scale defaults toDECIMAL(10,0)— zero digits after the point — so every value is rounded to a whole second on write:0.043s→00.6s→1Most checks finish well under a second, so they store
0and display as0.00s.Fix
New migration altering the column to
DECIMAL(10,6)(microsecond precision; max ~9999s). Dummy schema dump updated to match.Caveats
0were rounded on insert and cannot be recovered; only probe results recorded after the migration runs will be correct.37upright) via the appended migration path, so deploying the bumped gem fixes production. Host bump: basecamp/37upright (companion PR).🤖 Generated with Claude Code