Skip to content

v1.3 — build numbers keep naming commits that exist

Latest

Choose a tag to compare

@hpoul hpoul released this 19 Aug 13:32

Upgrade if you allocate build numbers from more than one machine. This
release closes the two issues v1.2 named as known, and seven more found
reviewing the fix — five of which failed silently.

Build numbers stopped naming commits that still exist

A build number recorded the commit's SHA as blob content, which keeps nothing
alive. Once the last branch containing that commit went away, git gc collected
it, and find-commit then succeeded while naming an object that is gone. Two
repositories using this tool were measured: 8 of 46 build numbers in one and 3
of 46 in the other pointed at commits reachable from no ref at all.

The allocation chain now takes the built commit as a second parent, so
reachability is a property of the ref rather than a job somebody has to
remember. Existing chains keep working; entries written before this release
cannot be repaired, because the objects they named are already gone.

Concurrent allocation

  • The push could not fail. One refspec constant served both fetch and push,
    and its + meant every push force-updated the remote — so the retry that
    exists for a lost race was unreachable code.
  • --force-with-lease was silently overridden by that same +. The two are
    contradictory and git does not say so.
  • The lease was observed from local refs, not from the remote it was pushed
    to, so it certified a value nothing had checked.
  • push fetched before pushing, force-updating and thereby destroying the
    very local state it had been asked to publish.
  • force-incr counted from the current commit's own note rather than from
    the shared counter. With HEAD on 1 and the counter on 3 it produced 2 — a
    number another commit already owned — and pushing it rolled the counter
    backwards, so the next allocation handed out 3 a second time.
  • force-incr recursed unboundedly, incrementing on every pass, so a remote
    that kept refusing burned a build number per attempt.
  • The retry returned the note it had just lost with, instead of refetching
    and reallocating.

Pushes are now atomic, leased against values read from the remote being pushed
to, bounded in attempts, and a run that gives up restores the refs it wrote.

And three that only showed on the failure paths

  • sync never published anything. It fetched and then pushed, and the fetch
    force-updated the local refs first — so the push was a no-op by construction.
    It pushes first now.
  • An unreachable remote read as an empty one, so a network failure looked
    like a repository with no allocations.
  • \t in a grep pattern is a tab on BSD and a literal t on GNU.

find-commit also no longer dies on a missing argument.