Files
ngit-grasp/1e2a-retry-individual-oids-on-not-our-ref.md
T

2.6 KiB

Retry Individual OIDs on "not our ref" Errors

ID: 1e2a

Problem

When git fetch requests multiple OIDs and encounters a "not our ref" error, git stops at the first missing OID and doesn't attempt to fetch the remaining OIDs. This means if we request 5 OIDs and the first one is missing, we never try the other 4 - even though they may exist on the remote.

Example scenario:

  • Request OIDs: [A, B, C, D, E]
  • Remote has: [B, C, D, E] but not A
  • Git fails on A and stops
  • Result: We never fetch B, C, D, E even though they're available

This is particularly problematic because:

  1. We may have state events (kind 30617) that are critical for repository state
  2. We may have PR refs that are less critical but still valuable
  3. We're wasting opportunities to fetch available data

Current behavior:

  • Single OID request: Returns clear error "remote missing only oid requested: {oid}"
  • Multi OID request: Logs WARNING and returns "remote missing oid {oid} (BUG: {n} other oids not attempted)"

Plan

  • Phase 1: Implement retry logic for "not our ref" errors

    • When fetch fails with "not our ref", extract the missing OID
    • Remove missing OID from request list
    • Retry fetch with remaining OIDs
    • Continue until all OIDs attempted or all are missing
    • Track which OIDs were missing vs successfully fetched
  • Phase 2: Integrate with throttling system

    • Ensure retries respect domain throttling limits
    • Don't count retries as separate requests for throttling purposes
    • Consider backoff if multiple OIDs are missing
  • Phase 3: Prioritize state events over PR refs

    • Separate OIDs by event kind (30617 state events vs others)
    • Fetch state event OIDs first
    • Fetch PR ref OIDs second
    • This ensures critical repository state is prioritized
  • Phase 4: Add metrics and logging

    • Track how often we hit this scenario
    • Log which OIDs were missing vs fetched
    • Monitor impact on sync performance

Progress

2026-01-23 [Session 16:00]

  • Created issue to track the bug
  • Committed short-term fix that improves error messages and warns about the bug
  • Commit: 9fd4350 "fix: improve 'not our ref' error messages and warn about multi-OID fetch bug"

Notes

  • Related code: src/purgatory/sync/context.rs:411-448 (fetch_oids error handling)
  • Git behavior confirmed by testing: git stops at first missing OID
  • Current warning helps identify when this bug is affecting sync
  • Proper fix requires retry loop with OID filtering
  • Must consider performance impact of multiple fetch attempts
  • Should track metrics to understand how often this occurs in production