Repository navigation
fix(control-plane): store execution VC created_at in UTC on SQLite - #1170
Closed
santoshkumarradha wants to merge 1 commit into
Closed
santoshkumarradha wants to merge 1 commit into
santoshkumarradha wants to merge 1 commit into
Conversation
StoreExecutionVC and StoreExecutionVCRecord wrote created_at with time.Now() in the host's zone. SQLite keeps it as text, and the created_after/created_before filters bind a UTC bound, so on a host west of UTC a VC created a moment ago sorted before a bound in the past and was filtered out; ORDER BY created_at likewise mixed rows written under different offsets. Writers now store UTC, and a one-time startup pass on SQLite rewrites rows an older build stored in the host's zone, keeping each row's instant. Postgres columns are timestamptz and are unaffected.
19 of 22 tasks
Member
Author
|
Folded into #1171 so all fixes get one review; commits unchanged. |
Contributor
📊 Coverage gateThresholds from
✅ Gate passedNo surface regressed past the allowed threshold and the aggregate stayed above the floor. |
Contributor
📐 Patch coverage gateThreshold: 80% on lines this PR touches vs
❌ Patch gate failed
How to fix
|
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.
Summary
On SQLite, execution VC
created_atwas written in the host's local zone, while the VC filters bind a UTC bound and compare the stored text. On any host west of UTC, a VC created a moment ago sorts before acreated_afterbound in the past and is dropped;ORDER BY created_atalso misorders rows written under different offsets (DST changes, a changedTZ).Fix:
Same class of bug as #1040 (execution timestamps compared lexically on SQLite). Postgres stores
timestamptzand is unaffected; the rewrite only runs on SQLite.Type of change
Evidence
Before (
origin/main,time.Local= UTC-5, new testTestStoreExecutionVCWritesCreatedAtInUTC):With the stored-text assertion removed, the user-visible effect on main:
After:
TestNormalizeExecutionVCTimestampsRewritesHostZoneRowsseeds a row written in a UTC-5 zone that is newer than a UTC row but sorts first as text, runs the rewrite, and asserts the newest VC lists first, the instant is unchanged, and the migration is recorded once and is a no-op on the second run.Test plan
cd control-plane && go build ./...go vet ./internal/storage/go test ./internal/storage/ -count=1go test ./internal/services/ ./internal/handlers/... -count=1Merge Danger
Door: one-way — on first start with this build, SQLite
execution_vcs.created_atvalues not already in UTC are rewritten in place (same instant, UTC spelling); an older build reads them back fine, but the original offset text is not restored.Blast Radius: low — one column of one table on SQLite only, batched, recorded in
schema_migrationsso it runs once; unparseable values are left untouched.