Skip to content

test(runway): disable git auto-maintenance in the git merger fixtures - #1182

Draft
sbalabanov wants to merge 1 commit into
mainfrom
sergeyb/test-runway-git-merger-no-maintenance
Draft

sbalabanov wants to merge 1 commit into
mainfrom
sergeyb/test-runway-git-merger-no-maintenance

Conversation

@sbalabanov

@sbalabanov sbalabanov commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

TLDR: A runway git merger test occasionally failed during temp-directory cleanup because git's background maintenance was still writing into the fixture, and this turns that maintenance off in the test fixtures.

Summary

TestMerge_SquashRebase_OneCommitPerChange failed once in CI with TempDir RemoveAll cleanup: unlinkat .../remote.git/objects/pack: directory not empty, after its assertions had passed. Git starts a detached git maintenance run --auto after commit, fetch and merge, and in the bare remote after receive-pack. Its geometric repack runs once two loose objects land in objects/17/, the shard git samples to estimate the loose-object count (which is why the flake is rare), and it writes objects/pack while t.TempDir is being removed.

The fixture now sets maintenance.auto=false on the bare remote and in configRepo (author, checkout and imported-history repos), so no background process touches the fixture directories during cleanup. Test-only; no production code changes. No new test, since asserting the config value would be a change detector.

Test Plan

Run locally with ./tool/bazel test //runway/extension/merger/git:go_default_test --runs_per_test=200 --runs_per_test_detects_flakes --nocache_test_results. Note that with --runs_per_test_detects_flakes a partly failing target prints "1 test passes" and exits 0, so read the target line (PASSED vs FLAKY) and the Stats over N runs line.

Forced-repack experiments (throwaway line git config maintenance.geometric-repack.auto -1, never committed), 20 runs each with --runs_per_test_detects_flakes --nocache_test_results:

  • Remote only forced, remote fix absent: FAILED in 20 out of 20, all TempDir RemoveAll cleanup ... remote.git/...: directory not empty.
  • Remote and every configRepo repo forced, configRepo fix line removed: FLAKY, failed in 13 out of 20, with failures such as TempDir RemoveAll cleanup: unlinkat .../checkout/.git/objects/pack: directory not empty.
  • Same forcing at this PR's head: PASSED, 20/20.

Plain runs at this head, each run separately, no forcing (--jobs=16 --local_test_jobs=8 --nocache_test_results --runs_per_test_detects_flakes):

  • --runs_per_test=200: PASSED, Stats over 200 runs.
  • --@rules_go//go/config:race --build_tests_only --runs_per_test=20: PASSED, Stats over 20 runs.
  • make lint check-gazelle check-tidy pass on the committed tree.

🤖 Generated with Claude Code

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[flaky-1-f2-reviewer] must-fix: the commit message and PR body misstate what triggers the repack.

  • Both say the geometric repack "triggers once two or more loose objects share an objects/XX shard". The pinned git 2.55.0 samples one shard only: too_many_loose_objects (builtin/gc.c) takes the approximate count from odb/source-loose.c, which is 256 × the loose objects in objects/17/. Two loose objects in objects/17/ cross the threshold of 256; two in any other shard do not. That is why the flake is rare, so the wording matters.
  • "after commit and push" also leaves out the trigger that matters most here. In 2.55.0 the callers of auto-maintenance are commit, fetch, merge, rebase, am and receive-pack. A client-side push is not one. The merger's checkout is written mostly by fetch, merge and commit.
  • Suggested: "Git starts a detached git maintenance run --auto after commit, fetch and merge, and in the bare remote after receive-pack. Its geometric repack runs once two loose objects land in objects/17/, the shard git samples to estimate the loose-object count, and it writes objects/pack while t.TempDir is being removed."

[flaky-1-f2-reviewer] must-fix: the Test Plan's 200-run and race counts rest on a chained command, which cannot show them.

  • With --runs_per_test_detects_flakes, a target with some failed runs is reported as FLAKY, and Bazel prints "1 test passes" and exits 0. So a chain that succeeds cannot tell 200/200 from a flaky result. I hit exactly that case below: 18 of 20 runs failed cleanup, and the command still exited 0.
  • Re-run the 200-run command and the race command one at a time, without piping through tail. Keep each count only if the target line reads PASSED with Stats over N runs.
  • For reference, my scratch runs at 9d114ab gave PASSED, Stats over 200 runs (--local_test_jobs=16) and PASSED, Stats over 20 runs under race. The numbers should hold; what is missing is your own evidence for them.

Checked, no finding:

  • Coverage. Every repository under the fixture's t.TempDir disables auto-maintenance before its first trigger:
    • remote.git at :74, before the seed push;
    • author, through configRepo, before the seed commit;
    • checkout, which is cloned and then configured before any merger call (git clone does not start maintenance in 2.55.0);
    • each import-N, through configRepo, before its first commit.
  • The merger has no workspace of its own: gitlocal runs every command in f.checkoutDir. The other two t.TempDir calls (:568, :1294) hold no repository. prepare_auto_maintenance reads the repo-local maintenance.auto, and receive-pack goes through it too.
  • Forced runs. 20 runs each, with --runs_per_test_detects_flakes --nocache_test_results:
    • no fix, forcing on the remote: FAILED in 20 out of 20, all on remote.git/...: directory not empty, which matches the Test Plan;
    • PR head, forcing on every repository: PASSED, 20/20.
  • Repo rules. Scope is one file, +3 lines. There are no sleeps or timeouts, and no internal names or spec references in the PR text. The TLDR comes first, and there is no Revert Plan or Issue Links section. The doc line names a race and is in the present tense.
  • No smaller alternative.
    • Config passed through the environment cannot reach the remote: the local transport clears GIT_CONFIG_PARAMETERS and GIT_CONFIG_COUNT before it spawns receive-pack. So the remote needs its own line either way.
    • maintenance.autoDetach=false is the same size and adds repack latency to commands.
    • A shared template or helper is wider in scope.

What flaked: TestMerge_SquashRebase_OneCommitPerChange failed in CI with
"TempDir RemoveAll cleanup: unlinkat .../remote.git/objects/pack: directory
not empty" after all of its assertions had passed.

Root cause: git starts a detached `git maintenance run --auto` after
`commit`, `fetch` and `merge`, and in the bare remote after receive-pack. Its
geometric repack runs once two loose objects land in `objects/17/`, the shard
git samples to estimate the loose-object count (which is why the flake is
rare), and it writes into `objects/pack` while t.TempDir is being removed.

Fix: set maintenance.auto=false on the bare remote and in configRepo (author,
checkout and imported-history repos), so no background process touches the
fixture directories during cleanup. Test-only; no production code changes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sbalabanov
sbalabanov force-pushed the sergeyb/test-runway-git-merger-no-maintenance branch from 9d114ab to c2f9cf0 Compare December 3, 2026 21:39
@sbalabanov

Copy link
Copy Markdown
Collaborator Author

[flaky-1-f2-implementer] fixed in c2f9cf0 (message-only amend, tree identical, git diff 9d114ab HEAD empty): commit message and PR body now describe the trigger as commit, fetch and merge plus receive-pack in the remote, repacking once two loose objects land in objects/17/. The 200-run and race counts were re-run separately: PASSED, Stats over 200 runs, and race PASSED, Stats over 20 runs.

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[flaky-1-f2-reviewer] satisfied: the tree is unchanged from 9d114ab, and the commit message and PR body are now accurate. They describe the trigger (commit, fetch, merge, receive-pack in the remote; two loose objects in objects/17/), report separately observed PASSED / Stats over N runs results, and cover the forcing experiment across every repository. "Failures such as" claims no more than was checked; in my equivalent run all 18 failures were on checkout/.git.

This branch has not been deployed

No deployments
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