Skip to content

Fix backfill race for issue solved_by_pr linkage#29

Closed
owldev127 wants to merge 1 commit into
entrius:testfrom
owldev127:fix/backfill-solved-by-pr-race
Closed

Fix backfill race for issue solved_by_pr linkage#29
owldev127 wants to merge 1 commit into
entrius:testfrom
owldev127:fix/backfill-solved-by-pr-race

Conversation

@owldev127
Copy link
Copy Markdown

@owldev127 owldev127 commented May 11, 2026

Related Issues

Closes #28

Summary

This PR fixes a backfill ordering bug where issues.solved_by_pr could remain null even when a merged PR already referenced the issue in its closing links.

The root problem is that PR backfill and issue backfill have different responsibilities:

  • PR backfill populates PR rows, including closingIssueNumbers
  • issue backfill populates the actual issues rows that solved_by_pr is written onto

Without backfilling issues first, the mirror cannot safely reconcile issues.solved_by_pr:

  • some linked issue rows may not exist yet, so there is nothing to update
  • existing issue rows may be stale (for example reopened issues should clear solved_by_pr)
  • downstream consumers rely on current issue rows, not just PR-side closing links

Fix

  • store closingIssueNumbers during initial PR backfill
  • backfill issues before dependent follow-up PR work
  • reconcile issues.solved_by_pr from merged PR closing links after both PR and issue rows exist
  • choose the earliest merged closing PR as the solver when multiple merged PRs reference the same issue

Why still backfillIssues() Is Required

backfillPullRequests() alone is not enough. It tells us which PRs claim to close which issues, but it does not guarantee that the corresponding issue rows exist or are current in the database.

  • linked issues exist as rows that can receive solved_by_pr
  • open/reopened issues can clear stale solved_by_pr
  • issue metadata used by downstream validation remains fresh

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

Checklist

  • I have read the Contributing Guide
  • Code builds without errors
  • New and existing tests pass (if applicable)
  • Documentation updated (if applicable)
  • No unnecessary dependencies added

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 11, 2026
@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented May 13, 2026

The backfill race here is fixed by moving backfillIssues ahead of the PR_METADATA enqueue loop in handleBackfill — a three-line ordering change. This PR's broader rewrite (inlining closing_issue_numbers into every-PR-every-backfill, then reconciling solved_by_pr via SQL) takes on correlated failure with PR #78's GraphQL partial-response handling: a partial response on the new inline fetch would wipe closing_issue_numbers for many PRs at once, and the reconcile would then null out the corresponding solved_by_pr values. Closing.

@anderdc anderdc closed this May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backfill can miss solved_by_pr links when PR metadata runs before issues exist

2 participants