Skip to content

Fix timestamptz precision in native Value hint retry_at - #20697

Merged
pelikhan merged 1 commit into
mainfrom
pelikhan/native-value-hints-race
Nov 12, 2026
Merged

pelikhan merged 1 commit into
mainfrom
pelikhan/native-value-hints-race

Conversation

@pelikhan

Copy link
Copy Markdown
Collaborator

TestNativeValueHintsFenceConcurrentInvalidationAndAcknowledgement fails on Linux CI ("Go unit tests (storage, shard 2)") on both PRs and main, with "failed acquisition acknowledged dirty evidence".

This is not a concurrency race. Fencing works correctly: the failing hint {Dirty:17 Processed:16} is the expected state. The assertion that fails is RetryAt.Equal(now.Add(time.Hour)). PostgreSQL timestamptz stores microseconds and rounds, while Go's time.Now() on Linux carries nanoseconds, so the stored retry time never round-trips. macOS clocks are microsecond-resolution, which is why the test passes locally.

Changes

  • CompleteValueHint truncates retry_at to microseconds before storing it, so callers get back exactly what they wrote (and rounding can never move it later).
  • The test truncates now to microseconds, matching production callers. All assertions are unchanged.

Validation

  • Linux (golang:1.27.3 + Postgres 16): the old code reproduces the exact CI error 5/5; the fixed code passes 5/5.
  • macOS: go test ./internal/postgresx -run TestNativeValueHints -count=50 -race passes.

PostgreSQL timestamptz stores microseconds and rounds, so a nanosecond
retry time (Linux clocks) never round-trips. The fencing test failed
deterministically on CI comparing RetryAt; fencing itself was correct.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review November 12, 2026 17:49
@pelikhan
pelikhan requested a review from mnkiefer as a code owner November 12, 2026 17:49
@pelikhan
pelikhan merged commit 64cc27f into main Nov 12, 2026
39 of 44 checks passed
@pelikhan
pelikhan deleted the pelikhan/native-value-hints-race branch November 12, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant