git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Protecting old temporary objects being reused from concurrent "git gc"?

From
Jeff King <peff@peff.net>
Date
Nov 17, 2016, 01:04 UTC
Message-ID
<20161117010449.6k3cwo3njvrid4jy@sigill.intra.peff.net>
In-Reply-To
<xmqq1sybqmjt.fsf@gitster.mtv.corp.google.com>
On Wed, Nov 16, 2016 at 10:58:30AM -0800, Junio C Hamano wrote:
Show 15 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > I suspect the issue is that read-tree populates the cache-tree index
> > extension, and then write-tree omits the object write before it even
> > gets to write_sha1_file().
> 
> Wait a minute.  The entries in the index and trees in the cache-tree
> are root of "still in use" traversal for the purpose of pruning,
> which makes the "something like this" patch unnecessary for the real
> index file.
> 
> And for temporary index files that is kept for 6 months, touching
> tree objects that cache-tree references is irrelevant---the blobs
> recorded in the "list of objects" part of the index will go stale,
> which is a lot more problematic.

I think the case that is helped here is somebody who runs "git write-tree" and expects that the timestamp on those trees is fresh. So even more a briefly used index, like:

  export GIT_INDEX_FILE=/tmp/foo
  git read-tree ...
  git write-tree
  rm -f $GIT_INDEX_FILE

we'd expect that a "git gc" which runs immediately after would see those trees as recent and avoid pruning them (and transitively, any blobs that are reachable from the trees). But I don't think that write-tree actually freshens them (it sees "oh, we already have these; there is nothing to write").

I could actually see an argument that the read-tree operation should freshen the blobs themselves (because we know those blobs are now in active use, and probably shouldn't be pruned), but I am not sure I agree there. If only because it is weird that an operation which is otherwise read-only with respect to the repository would modify the object database.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 13 in “Protecting old temporary objects being reused from concurrent "git gc"?”
  1. Matt McCutchenNov 15, 2016
  2. Jeff KingNov 15, 2016
  3. Matt McCutchenNov 15, 2016
  4. Jeff KingNov 15, 2016
  5. git-gc.txt: expand discussion of races with other processesMatt McCutchen, Nov 15, 2016
  6. Matt McCutchenNov 15, 2016
  7. Junio C HamanoNov 15, 2016
  8. Jeff KingNov 16, 2016
  9. Junio C HamanoNov 16, 2016
  10. Junio C HamanoNov 16, 2016
  11. Jeff KingNov 17, 2016
  12. Re* Protecting old temporary objects being reused from concurrent "git gc"?Junio C Hamano, Nov 17, 2016
  13. Jeff KingNov 17, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.