Skip to content

perf(coderd/x/gitsync): poll merged PRs hourly - #31922

Merged
mafredri merged 7 commits into
mainfrom
mafredri/gitsync-merged-pr-refresh-interval
Nov 13, 2026
Merged

mafredri merged 7 commits into
mainfrom
mafredri/gitsync-merged-pr-refresh-interval

Conversation

@mafredri

@mafredri mafredri commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Merged PRs cannot reopen, but their diff-status rows use the same two-minute TTL as open PRs. Set the TTL to one hour after a successful diff-status refresh of a merged PR.

For a row without workspace git reports or diff-status refresh errors, this reduces the nominal scheduled rate from 30 diff-status refreshes per hour to one. Open and closed PR TTLs, error backoffs, and git-report invalidation are unchanged.

Verified with: the full gitsync package tests, race detector, and make pre-commit.

Part of CODAGT-1543.

Decision log
  • One-hour TTL, not permanent exclusion or 24 hours. Titles and reviews can change after merging. Continue diff-status refreshes without delaying those metadata updates for a day.
  • Keep closed PRs on DiffStatusTTL. They can reopen. Select the TTL from the fetched PR state, including after resolving a different PR for the branch.
  • Preserve invalidation and discovery. A workspace agent git report (Worker.MarkStale) sets stale_at to the past. GET /api/v2/chats/{chat}/diff discovers a new open PR on a reused branch and sets the row's stale_at to the past; background polling still follows a stored PR URL.
  • Change successful diff-status refreshes only. Failed diff-status refreshes retain existing error backoffs, including two minutes for ordinary errors. Reducing repeated failures is follow-up work, not part of this PR.

🤖 Created with the help of Coder Agents.

@mafredri
mafredri temporarily deployed to main November 9, 2026 12:09 — with GitHub Actions Inactive
@mafredri
mafredri temporarily deployed to main November 9, 2026 12:09 — with GitHub Actions Inactive
@linear-code

linear-code Bot commented Nov 9, 2026

Copy link
Copy Markdown

CODAGT-1543

@mafredri
mafredri temporarily deployed to main November 9, 2026 13:00 — with GitHub Actions Inactive
@mafredri
mafredri temporarily deployed to main November 9, 2026 13:00 — with GitHub Actions Inactive
@mafredri

This comment has been minimized.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T20:07:38.637928Z 316c9e0 Manual request
ℹ️ 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.

@chatgpt-codex-connector

This comment has been minimized.

@mafredri
mafredri marked this pull request as ready for review November 9, 2026 14:54
@mafredri
mafredri temporarily deployed to main November 9, 2026 14:54 — with GitHub Actions Inactive
@pr-queue-manager
pr-queue-manager Bot requested a review from sreya November 9, 2026 14:56
coder-agents-review[bot]

This comment was marked as outdated.

@mafredri
mafredri force-pushed the mafredri/gitsync-merged-pr-refresh-interval branch from bd83b5a to 316c9e0 Compare November 9, 2026 19:40
@mafredri
mafredri temporarily deployed to main November 9, 2026 19:40 — with GitHub Actions Inactive
@mafredri

This comment has been minimized.

@mafredri

This comment has been minimized.

@chatgpt-codex-connector

This comment has been minimized.

coder-agents-review[bot]

This comment was marked as outdated.

@mafredri

This comment has been minimized.

@mafredri

This comment has been minimized.

@chatgpt-codex-connector

This comment has been minimized.

coder-agents-review[bot]

This comment was marked as outdated.

@mafredri
mafredri force-pushed the mafredri/gitsync-merged-pr-refresh-interval branch from 316c9e0 to 9e801c6 Compare November 9, 2026 22:39
@mafredri
mafredri temporarily deployed to main November 9, 2026 22:39 — with GitHub Actions Inactive
@mafredri
mafredri temporarily deployed to main November 9, 2026 22:39 — with GitHub Actions Inactive
@pr-queue-manager
pr-queue-manager Bot requested review from DanielleMaywood and removed request for sreya November 13, 2026 10:40
Comment thread coderd/x/gitsync/gitsync_test.go Resolved

@DanielleMaywood DanielleMaywood left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code change is fine, test is questionable

Merged pull requests cannot reopen, so their status does not need the
two-minute polling interval used for open and closed pull requests.
Refresh them hourly to reduce background provider requests while still
picking up metadata changes.

Git activity continues to mark merged rows stale for the next worker
tick.
Name the test for the state-based scheduling contract it protects and
explain why its cached state differs from the provider result. Use the
shared default interval for open and closed PR expectations, consistent
with the worker coverage.
Exercise merged PR invalidation with a chat bound to the calling
workspace so the integration test satisfies the workspace checks and
reaches the refresh path.
State-based TTL checks must distinguish the stored PR state from the
fetched PR state. Separate the merged PR fixture, invalidation, and
metadata checks so the scheduling contract is visible without tracing
the setup code.
Stored PR state can outlive a URL replacement, and branch resolution
can replace the first fetched status. Cover both boundaries so later
TTL changes cannot slow a newly discovered open PR to the merged TTL.

Keep the SQL invalidation test clock behind database time so a small
clock difference does not prevent its only tick from acquiring the row.
The branch-mismatch TTL expectations depend on the mocked PR states.
State that relationship beside the table and share one test-only TTL
value so its link to the private production constant is explicit.
Tests kept their own copy of the private one-hour TTL. Export it like
DiffStatusTTL so tests use the constant itself.
@mafredri
mafredri force-pushed the mafredri/gitsync-merged-pr-refresh-interval branch from 9e801c6 to eb17606 Compare November 13, 2026 11:00
@mafredri
mafredri temporarily deployed to main November 13, 2026 11:00 — with GitHub Actions Inactive
@mafredri
mafredri enabled auto-merge (squash) November 13, 2026 11:05
@mafredri
mafredri merged commit 5c9d74e into main Nov 13, 2026
29 checks passed
@mafredri
mafredri deleted the mafredri/gitsync-merged-pr-refresh-interval branch November 13, 2026 11:13
@mafredri
mafredri temporarily deployed to docs-preview November 13, 2026 11:13 — with GitHub Actions Inactive
@mafredri
mafredri temporarily deployed to main November 13, 2026 11:13 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 13, 2026

This branch was previously deployed

2 inactive deployments
docs-preview — eb17606d Deployed Nov 13, 2026 by mafredri via cleanup #32
main — eb17606d Deployed Nov 13, 2026 by mafredri via cla #256341
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants