Skip to content

fix(warehouse-sources): stamp Delta commit times in the snapshot pin test - #93155

Merged
trunk-io[bot] merged 4 commits into
masterfrom
fix/warehouse-parent-pin-test-clock
Sep 2, 2026
Merged

trunk-io[bot] merged 4 commits into
masterfrom
fix/warehouse-parent-pin-test-clock

Conversation

@pauldambra

@pauldambra pauldambra commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Problem

Anyone whose PR shares a Trunk merge-queue batch with a warehouse-sources shard can get thrown out of the queue by test_resolve_pins_to_last_completed_snapshot_while_parent_is_syncing failing with assert 1 == 0. It failed 3/3 attempts in both the batch run and the bisection run for #92922 (a cohorts-only PR), while master's own CI on the identical base commit (7e12bc8) passed.

The test writes a Delta table (v0), takes v0's commit timestamp from DeltaTable.history(), immediately overwrites (v1), then pins at that timestamp and expects v0. But delta-rs time travel does not compare against history() timestamps: get_version_timestamp / version_timestamp in delta-rs 1.6.1 return the _delta_log commit files' last_modified. On Linux, file mtimes come from the kernel's coarse clock and can lag the in-process clock by a scheduler tick, so on a fast runner both commit files can look older than v0's own timestamp. The binary search then lands on v1. Reruns don't help because the outcome tracks the runner's speed, not luck, and it never reproduces on macOS, where mtimes are fine-grained.

Changes

  • Replaces the in-branch change that fix(posthog-ai): convert remaining schema references to generated column tables #84280 carried to master for this same test (commit "fix(warehouse-sources): stabilize parent snapshot test"). That change rewrote the v1 commit's commitInfo.timestamp to v0's plus one millisecond. Delta-rs never reads that field for time travel, so the rewrite only worked because writing the file refreshed its mtime, and a probe confirmed it: with the file's mtime set back to the lagging value the pin still lands on v1. It also left the test without a comment saying why it does what it does.
  • The test stamps the two commit files with explicit, well-separated mtimes and pins between them, so the assertion is about the pin and not about which clock ticked first. This is also the production shape: finished_at sits strictly between the completed job's last commit and the next run's first one. The commits sit 2 minutes apart and the pin 1 minute after the first — the helper name and those offsets come from fix(warehouse-sources): pin the parent snapshot test to a stable clock #93192, which fixed the same test independently and is closed in favor of this PR.
  • A small _set_delta_commit_log_mtimes helper carries a comment on why delta-rs needs this, so the next person doesn't rediscover it. The json import fix(posthog-ai): convert remaining schema references to generated column tables #84280 added goes away with the rewrite it served.

No production code changes.

How did you test this code?

  • Rebased onto master after fix(posthog-ai): convert remaining schema references to generated column tables #84280 landed; the test passes locally under flox on the rebased branch, ruff is clean; the APIBaseTest-based classes in the file error locally only because no Postgres is running, which is unrelated to this change.
  • Reproduced the CI failure mechanism in a standalone script against deltalake 1.6.1: with the two commit files' mtimes forced to lag v0's history() timestamp by 1ms, load_as_version(v0_timestamp) loads version 1; with the explicit stamps used here, it loads version 0.
  • Evidence: bisection run 33608387907 and batch run 33604779252, both failing this test 3/3; master on the same base commit: 33607068880 green.
  • Not checked: I did not run this on a Linux runner myself; the fix removes the dependency on mtime granularity rather than tuning around it.

Note for a follow-up, not changed here: the resolve_parent_table_ref docstring describes the rollback as comparing finished_at against "Delta commit timestamps stamped by worker clocks". Against S3 it actually compares against S3's LastModified, which is S3's clock at second granularity.

Automatic notifications

  • Publish to changelog?

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code (Fable 5.1). Diagnosis started from the failed merge-queue job link: read the shard logs, compared the queue branch's base SHA against master's check runs, read the pinned delta-rs source for load_with_datetime, and reproduced the mtime-lag mechanism in a scratch script before touching the test. No repo skills were invoked. Skill updates capturing the lesson (writing-tests, fixing-flaky-tests, triaging-merge-queue-failures) are in a separate PR.

🤖 Generated with Claude Code

@pauldambra pauldambra self-assigned this Sep 2, 2026
@trunk-io

trunk-io Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-02T09:55:31.918923Z 6287f6b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team September 2, 2026 09:49
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6287f6b149

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@pauldambra

pauldambra commented Sep 2, 2026 •

Copy link
Copy Markdown
Member Author

Note

🤖 Automated comment by QA Swarm — not written by a human

Multi-perspective review: router (cheap-first pass) + delegated reviewers (qa-team, paul-reviewer, xp-reviewer, security-audit as warranted)

Verdict: ✅ APPROVE (round 2 @ 32945a2)

Re-review after the helper docstring became a comment block. No actionable findings; the router judged the change low-danger with high confidence and delegated nothing.

Key findings

  • None.

Convergence

  • None (single reviewer ran).

Reviewer summaries

Reviewer Assessment
🧭 router The docstring-to-comment conversion is complete: the comment explains why (delta-rs compares commit-file mtimes, which lag on Linux), carries no change-history language, and formats cleanly. import os sits in the stdlib block. Nothing cleared in round 1 changed. Danger LOW, confidence HIGH, no delegation.
Previous rounds (1)
  • round 1 @ 6287f6b — ✅ APPROVE: one-file test fix, router found nothing, no delegation.

Automated by QA Swarm — not a human review

@pauldambra pauldambra added the stamphog Request AI approval (no full review) label Sep 2, 2026
stamphog[bot]
stamphog Bot previously approved these changes Sep 2, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

Test-only change (no production code) that fixes a flaky assertion by stamping Delta commit-file mtimes instead of relying on coarse filesystem clocks; contained and reversible, well outside risky territory, so no independent assurance is required despite cross-team authorship.

Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 0L, 0F substantive, 23L/1F incl. docs/generated/snapshots — within ceiling
tier ✓ T0 auto-approve: T0-deterministic (23L, 1F, single-area, fix)
stamphog 2.0.0b4 .stamphog/policy.yml @ 32945a2 · reviewed head 32945a2

pauldambra and others added 2 commits September 2, 2026 11:37
…test

test_resolve_pins_to_last_completed_snapshot_while_parent_is_syncing pinned at the
v0 commit timestamp from DeltaTable.history() and expected v0 back. delta-rs time
travel compares against the _delta_log commit files' mtimes instead, and on Linux
those come from the kernel's coarse clock, so on a fast runner both commits can
look older than v0's own timestamp and the pin lands on v1. The test failed 3/3
attempts in two merge-queue runs and blocked unrelated PRs.

Stamp the two commit files with explicit, well-separated times and pin between
them, which is also the production shape: finished_at sits strictly between the
completed job's last commit and the next run's first one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…mment

Python test modules do not carry doc comments in this repo; the delta-rs mtime
rationale stays as an ordinary comment on the helper.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@stamphog
stamphog Bot dismissed their stale review September 2, 2026 11:00

A new stamphog review started for this PR — the fresh verdict replaces this approval.

stamphog[bot]
stamphog Bot previously approved these changes Sep 2, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

Test-only fix for a flaky mtime-dependent assertion, no production code touched, already carries a bot approval and a human approval with no unresolved concerns — not risky territory so cross-team authorship doesn't matter.

Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 0L, 0F substantive, 29L/1F incl. docs/generated/snapshots — within ceiling
tier ✓ T0 auto-approve: T0-deterministic (29L, 1F, single-area, fix)
stamphog 2.0.0b4 .stamphog/policy.yml @ aad15f1 · reviewed head aad15f1

@pauldambra
pauldambra force-pushed the fix/warehouse-parent-pin-test-clock branch from aad15f1 to 87a83f3 Compare September 2, 2026 11:07
pauldambra added a commit that referenced this pull request Sep 2, 2026
…ularity flakes

A warehouse-sources test that pinned a Delta snapshot at the previous write's
history() timestamp failed 3/3 attempts on the queue runner, passed on master
at the same base SHA, and Trunk's bisection blamed an unrelated PR (#92922,
fixed in #93155). The skills covering that path had three gaps: no rule
against deriving a cutoff from an earlier write's recorded time, no
recognition that an environment-dependent race fails every rerun yet passes
elsewhere, and no account of Trunk's bisection branches or of the
warehouse-sources exclusion from the quarantine gate.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…mit gap

Adopts the naming and timing from #93192: the helper says it sets commit log
mtimes and takes the whole timeline in one call, and the two commits sit 2
minutes apart with the pin 1 minute after the first.

Generated-By: PostHog Desktop
Task-Id: 4c55bc40-1d25-42fe-9036-908e21493bd1
@stamphog
stamphog Bot dismissed their stale review September 2, 2026 12:35

A new stamphog review started for this PR — the fresh verdict replaces this approval.

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review did not complete.

Stamphog hit an error and produced no verdict for this commit.

Push a new commit to try again.

Generated-By: PostHog Desktop
Task-Id: 7ee59145-d7a0-41f6-8de6-ab58a8cc10a0

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

Test-only fix (no production code touched) that stamps explicit Delta commit-log mtimes instead of relying on unreliable filesystem clock behavior; diff matches the description exactly, and a human reviewer already approved. Not risky territory, so cross-team authorship is just a routing note, not a blocker.

Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 0L, 0F substantive, 27L/1F incl. docs/generated/snapshots — within ceiling
tier ✓ T0 auto-approve: T0-deterministic (27L, 1F, single-area, fix)
stamphog 2.0.0b4 .stamphog/policy.yml @ 38660af · reviewed head 38660af

@trunk-io
trunk-io Bot merged commit 5ee40de into master Sep 2, 2026
205 checks passed
@trunk-io
trunk-io Bot deleted the fix/warehouse-parent-pin-test-clock branch September 2, 2026 16:54
@deployment-status-posthog

deployment-status-posthog Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-09-02 17:49 UTC Run
prod-us ✅ Deployed 2026-09-03 08:35 UTC Run
prod-eu ✅ Deployed 2026-09-03 08:36 UTC Run

dmarticus added a commit that referenced this pull request Sep 4, 2026
…test (#93155)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
dmarticus added a commit that referenced this pull request Sep 4, 2026
…test (#93155)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
dmarticus added a commit that referenced this pull request Sep 4, 2026
…test (#93155)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
webjunkie added a commit that referenced this pull request Sep 7, 2026
… snapshot pin test

The merge kept this branch's busy-wait next to master's explicit mtime
stamping (#93155), which removed the timestamp the wait referenced.
Master's fix supersedes the wait.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants