Skip to content

fix(open-knowledge): serialize shadow gc against the write path (#2743)#690

Merged
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync
Jul 19, 2026
Merged

fix(open-knowledge): serialize shadow gc against the write path (#2743)#690
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync

Conversation

@inkeep-oss-sync

Copy link
Copy Markdown
Contributor

Copybara-translated 1 Inkeep OSS change. Rebase-merge this PR so the prepared commit lands directly on public main.

* fix(server): serialize shadow gc against the write path via shadow op gate

git gc deletes newly-packed loose objects and emptied objects/xx fan-out
dirs; a concurrent git add / hash-object -w writing into those dirs fails
transiently (EINVAL observed on macOS, escaping git's ENOENT-only retry).
The maintenance coordinator serialized maintenance legs against each other
but not against shadow mutators, so a background gc could fail an in-flight
flush commit (the A1 flake, 6-14 percent per run measured).

Add ShadowOpGate (per shadow gitDir): mutators take shared holds, the gc
leg takes an exclusive hold that drains in-flight mutators and briefly
queues new ones. Deadlock-free by construction (a pending exclusive never
blocks new shared entries, so nested mutator holds cannot deadlock).
Wrap every shadow mutation entry point; A2 pins gc against a sustained
commit stream.

* test(server): review-response hardening for the shadow op gate

Address claude-review suggestions on #2743: warn when an exclusive
acquisition waits >60s on the mutator drain (starvation observability),
document buildWipTree's reliance on the prune grace window across its
split gate hold, count actual (not attempted) legacy-ref deletions in
sweepLegacyShadowRefs, and add the no-barging top-level-mutator and
exclusive-error-release gate tests.

GitOrigin-RevId: 90f22c66540c9ce6cf03b7d7ba13f99c000af66d
@inkeep-oss-sync
inkeep-oss-sync Bot merged commit 0aea68a into main Jul 19, 2026
@inkeep-oss-sync
inkeep-oss-sync Bot deleted the copybara/sync branch July 19, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant