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

Re: [PATCH] Enable core.fsyncObjectFiles by default

From
Theodore Ts'o <tytso@mit.edu>
Date
Jun 24, 2015, 14:30 UTC
Message-ID
<20150624143007.GC14324@thunk.org>
In-Reply-To
<xmqqegl1brjb.fsf@gitster.dls.corp.google.com>
On Tue, Jun 23, 2015 at 10:32:08PM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> 
> Regarding loose object files, given that we write to a temporary,
> optionally fsync, close and then move to the final name, would we
> still see partially written file if we omit the fsync, or would the
> corruption be limited to either empty or missing?

*Most* of the time the corruption will be an empty or missing file. It's possible that the file could be partially written. This is a relatively low-probability event, with the probability going up if the object file is large, and/or if the system is under memory pressure.

Show 8 quoted lines
> The reason I am wondering is because the codepath to create an
> object (i.e. "update-index --add", "hash-object -w", or "add") first
> checks if a packed or a loose object file _exists_ and if so
> bypasses writing the same thing anew, but the existence check for a
> loose object is to merely making sure that access(F_OK) (and
> optionally utime()) succeeds.  If the potential breakage is limited
> to truncation to empty, then we could replace it with stat(2) and
> st.st_size check, as no loose object file can be empty.

It would certainly be a good thing to do a st_size check; it can't possible hurt, and it will catch a large number of failures after a power failure. I could also imagine some hueristics that force an fsync if the object file is larger than a certain size (say, 4k if you are very paranoid, a few hundred kilobytes if you are less so), but past a certain point, it might be better just to tell the user to use fsyncObjectFiles and be done with it.

						- Ted
Previous: Junio C HamanoNext: Duy Nguyen
Message 5 of 8 in “Enable core.fsyncObjectFiles by default”
  1. Enable core.fsyncObjectFiles by defaultStefan Beller, Jun 23, 2015
  2. Junio C HamanoJun 23, 2015
  3. Theodore Ts'oJun 23, 2015
  4. Junio C HamanoJun 24, 2015
  5. Theodore Ts'oJun 24, 2015
  6. Duy NguyenJun 24, 2015
  7. Jeff KingJun 24, 2015
  8. Junio C HamanoJun 24, 2015

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.