From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Jonathan Nieder <jrnieder@gmail.com>,
Nathan Neulinger <nneul@neulinger.org>,
Santiago Torres <santiago@nyu.edu>,
git@vger.kernel.org,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: git status always modifies index?
Date: Mon, 27 Nov 2017 09:47:20 +0900 [thread overview]
Message-ID: <xmqq7euch7jb.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20171126192749.GC1501@sigill> (Jeff King's message of "Sun, 26 Nov 2017 14:27:49 -0500")
Jeff King <peff@peff.net> writes:
> I'm not sure I agree. Lockless writes are actually fine for the original
> use case of --no-optional-locks (which is a process for the same user
> that just happens to run in the background).
The phrase "lockless write" scares me---it sounds as if you
overwrite the index file no matter what other people (including
another instance of yourself) are doing to it.
Side note: What 'use-optional-locks' actually does is not to
give any file descriptor to write into when we invoke the
wt-status helpers (which would want to make an opportunistic
update to the index under the lock), so "--no-optional-locks" is
quite different from "lockless write". Whew. It is part of
what "semantically read-only things do not write" would have
been.
How would a true "lockless write" that is OK for background
opportunistic refresh work? Read, compute and then open the final
index file under its final name for writing and write it out,
without involving any rename? As long as it finishes writing the
result in full and closes, its competing with a real "lockful write"
would probably be safe when it loses (the lockful one will rename
its result over to the refreshed one). It cannot "win" the race by
writing into the temporary lock file the other party is using ;-)
But it may lose the race in a messy way---the lockful one tries to
rename its result over to the real index, which the lockless one has
still open and writing. Unix variants are probably OK with it and
the lockless one would lose gracefully, but on other platforms the
lockful one would fail to rename, I suspect? Or the lockless one
can crash while it is writing even if there is no race.
Or do you mean something different by "lockless write"?
next prev parent reply other threads:[~2017-11-27 0:47 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-22 15:19 git status always modifies index? Nathan Neulinger
2017-11-22 15:30 ` Santiago Torres
2017-11-22 15:37 ` Nathan Neulinger
2017-11-22 16:10 ` Santiago Torres
2017-11-22 16:20 ` Nathan Neulinger
2017-11-22 16:24 ` Santiago Torres
2017-11-22 20:27 ` Jonathan Nieder
2017-11-22 21:17 ` Jeff King
2017-11-22 21:56 ` Jonathan Nieder
2017-11-22 22:06 ` Jeff King
2017-11-25 21:55 ` Johannes Schindelin
2017-11-26 19:25 ` Jeff King
2017-11-26 21:55 ` Johannes Schindelin
2017-11-27 5:24 ` Jeff King
2017-11-27 6:03 ` Junio C Hamano
2017-11-27 20:50 ` Johannes Schindelin
2017-11-27 6:04 ` [PATCH] git-status.txt: mention --no-optional-locks Jeff King
2017-11-27 6:07 ` Junio C Hamano
2017-11-27 10:22 ` Kaartic Sivaraam
2017-11-27 20:54 ` Johannes Schindelin
2017-11-27 20:44 ` git status always modifies index? Johannes Schindelin
2017-11-27 20:49 ` Jonathan Nieder
2017-11-26 3:32 ` Junio C Hamano
2017-11-26 9:35 ` Junio C Hamano
2017-11-27 4:43 ` Jeff King
2017-11-27 4:56 ` Junio C Hamano
2017-11-27 5:00 ` Jeff King
2017-11-27 20:57 ` Jonathan Nieder
2017-11-27 22:50 ` Jeff King
2017-12-03 0:37 ` Junio C Hamano
2017-11-26 19:27 ` Jeff King
2017-11-27 0:47 ` Junio C Hamano [this message]
2017-11-27 6:12 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq7euch7jb.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
--cc=jrnieder@gmail.com \
--cc=nneul@neulinger.org \
--cc=peff@peff.net \
--cc=santiago@nyu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.