Repository navigation
fix(gitvcs): answer RecoveryHeadContained with one rev-list walk - #165
bferanmi806-sketch wants to merge 1 commit into
Conversation
RecoveryHeadContained ran git merge-base --is-ancestor once per remote ref while pool recovery holds the state lock, blocking every pool command for minutes to hours on repos with thousands of remote-tracking refs. One rev-list walk answers the identical ancestry question: rev-list prints commits reachable from HEAD but not from any exclusion (--remotes plus the show-ref-verified base refs); empty output means HEAD is contained. All Git failures still fail closed to false, and no locking changes. Refs kunchenguid#163.
|
Speaking as Kun's firstmate: Reviewed tip
VISION.md per-rule (inspected tip
contract-class: restore — same class as #164. Preferring sibling #164 (@nikolauska): ready (not draft), no-mistakes green, Greptile 5/5, design.md + process-count regression test, live 5001-ref evidence. When #164 merges we will close this leftover with thanks. If you want this tip to compete, mark ready-for-review and re-raise via no-mistakes so attestation matches the head — waiting on you for those, not a captain hold. No security risk on the diff. |
|
| repoDir := setupContainmentRepo(t) | ||
| mustGit(t, repoDir, "reset", "--hard", "HEAD~1") | ||
|
|
||
| assertContainment(t, repoDir, "", true) |
There was a problem hiding this comment.
Multiple remote refs remain untested
The remote-containment fixture creates only origin/main. As a result, these tests never check whether the new walk finds a containing ref among several remote-tracking refs, or exercise the many-ref case that caused the lock stall. A multi-ref regression case would guard the behavior this change is meant to preserve.
Knowledge Base Used: Git workspace backend
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Speaking as Kun's firstmate: closing as leftover. Sibling #164 (same #163 restore — single |
Fixes #163. DRAFT for review; please do not merge yet (see Unresolved).
Root cause
Since 3.1.0 (#159), recoverQuarantinedEntries runs under the pool state lock before every pool command. For each recovered slot it calls RecoveryHeadContained (internal/vcs/gitvcs/recovery.go), which spawned one git merge-base --is-ancestor HEAD process per ref under refs/remotes, stopping at the first containing ref. With thousands of remote-tracking refs and a HEAD contained nowhere (or late in sort order), every status/get/return blocked for minutes to hours while holding the lock.
Design rationale
One git rev-list -n 1 HEAD --not --remotes [] answers the identical ancestry question with a single commit walk: rev-list prints commits reachable from HEAD but not from any exclusion, and because containment is ancestor-closed (a ref containing HEAD contains all of HEAD's ancestors), empty output is exactly HEAD-is-contained. Kept deliberately narrow per the issue's preferred option:
Tests run
Limitations / unresolved