From: Max Kirillov <max@max630.net>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: Max Kirillov <max@max630.net>, Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org
Subject: Re: [PATCH/RFC 1/2] sha1_file: close all pack files after running
Date: Fri, 2 Oct 2015 22:06:46 +0300 [thread overview]
Message-ID: <20151002190646.GC26154@wheezy.local> (raw)
In-Reply-To: <33b74e875c7298f67640f5850e88c152@dscho.org>
On Fri, Oct 02, 2015 at 12:05:55PM +0200, Johannes Schindelin wrote:
> Hi Max,
>
> On 2015-10-01 05:29, Max Kirillov wrote:
>> When a builtin has done its job, but waits for pager or not waited
>> by its caller and still hanging it keeps pack files opened.
>> This can cause a number of issues, for example on Windows git gc
>> cannot remove the packs.
>
> I did not experience that issue. In any case, closing the
> packs after the builtin function has returned might not
> change anything anyway because we are about to `exit()`
> and that's that.
Steps to reproduce:
1. install the latest git-for-windows, 2.6.0.windows.1
2. run the script in the end of message
3. remember the directory name, press the enter as it asks
4. in the less scrool down
Then inspect the processes git.exe and less.exe with Process
Explorer of something you find convenient. Both processes
should have opened the pack file, and git.exe should have it
mapped (I found it in the "View"->"Lower Pane views"->"Dlls").
Then, if you run another bash window, cd to the repository
and run "git repack -a -d", it should print:
----
$ git repack -a -d
Counting objects: 3001, done.
Compressing objects: 100% (1003/1003), done.
Writing objects: 100% (3001/3001), done.
Total 3001 (delta 997), reused 3001 (delta 997)
Unlink of file '.git/objects/pack/pack-e1b0e3ac01ff8d79a77648de3370f49b93c58a8b.pack' failed. Should I try again? (y/n)
----
I would like the git gc to succeed, because I run it as a
scheduled task nightly and feel a bit annoyed by the opened
windows which wait for me to say yes (after exiting pager).
So, the fix is needed approximately in that place, after
running any builtin command.
For your case, I think, the same close_all_packs() should be
invoked before the repacking.
> The convention in Git seems to call things _gently rather
> than _nodie:
Thanks, will change it if the idea is welcomed.
>> -void close_pack_windows(struct packed_git *p)
>> +static int close_pack_windows_nodie(struct packed_git *p)
>> {
>> while (p->windows) {
>> struct pack_window *w = p->windows;
>>
>> if (w->inuse_cnt)
>> - die("pack '%s' still has open windows to it",
>> - p->pack_name);
>> + return 1;
>> +
>> munmap(w->base, w->len);
>> pack_mapped -= w->len;
>> pack_open_windows--;
>> p->windows = w->next;
>> free(w);
>> }
>> +
>> + return 0;
>> +}
>
> And while we're at it, why not teach that function a new
> parameter `int close_pack_fd`?
I think "close windows" should close windows, if it also
closes pack fd probably should be another name. But current
code seems quite logical. Close the packs, and run closing
windows from it.
> There is another problem: when we cannot close the pack
> window, we cannot really continue, can we?
Yes we can, unlocking of the window is not needed for the
current process to do what it intended to do, it would just
interfere with concurrent git gc.
For the clone case probably die would be appropriate. If you
feel like it worth complicating the code we might search for
some solution.
--
Max
The script:
--------- ./t-windows-pack-close.sh ---------
#!/bin/sh
set -e
TEST_DIR=`mktemp -d`
t_git() {
git --work-tree="$TEST_DIR" --git-dir="$TEST_DIR/.git" "$@"
}
t_git init
for i in $(seq 1000)
do
echo "commit$i" >"$TEST_DIR/commit.$i"
t_git add "commit.$i"
t_git commit -m "commit$i" -q
done
t_git repack
pack_path=$(find "$TEST_DIR/.git/objects/pack" -name "pack-.pack")
echo "dir: $TEST_DIR"
echo press enter to start git log
read
t_git -c core.packedGitWindowSize=100 log
-----------------------------
next prev parent reply other threads:[~2015-10-02 19:06 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-28 19:44 [PATCH] clone --dissociate: avoid locking pack files Johannes Schindelin
2015-09-30 19:28 ` Max Kirillov
2015-09-30 19:42 ` Junio C Hamano
2015-10-01 3:29 ` [PATCH/RFC 0/2] close packs files when they are not needed Max Kirillov
2015-10-01 3:29 ` [PATCH/RFC 1/2] sha1_file: close all pack files after running Max Kirillov
2015-10-02 10:05 ` Johannes Schindelin
2015-10-02 10:13 ` Johannes Schindelin
2015-10-02 19:21 ` Max Kirillov
2015-10-04 14:53 ` Johannes Schindelin
2015-10-05 4:57 ` Max Kirillov
2015-10-05 9:03 ` Johannes Schindelin
2015-10-02 19:06 ` Max Kirillov [this message]
2015-10-02 20:06 ` Max Kirillov
2015-10-01 3:29 ` [PATCH/RFC 2/2] sha1_file: set packfile to O_CLOEXEC at open Max Kirillov
2015-10-02 10:08 ` Johannes Schindelin
2015-10-01 4:39 ` [PATCH] clone --dissociate: avoid locking pack files Max Kirillov
2015-10-05 18:32 ` Johannes Schindelin
2015-10-05 20:29 ` [PATCH v2 0/4] Fix locking issues on Windows with `git clone --dissociate` Johannes Schindelin
2015-10-05 20:29 ` [PATCH v2 1/4] Demonstrate a Windows file locking issue " Johannes Schindelin
2015-10-05 20:30 ` [PATCH v2 2/4] Consolidate code to close a pack's file descriptor Johannes Schindelin
2015-10-05 20:57 ` Junio C Hamano
2015-10-05 21:52 ` Johannes Schindelin
2015-10-05 22:15 ` Junio C Hamano
2015-10-06 13:42 ` Johannes Schindelin
2015-10-05 20:33 ` [PATCH v2 3/4] Add a function to release all packs Johannes Schindelin
2015-10-05 20:33 ` [PATCH v2 4/4] clone --dissociate: avoid locking pack files Johannes Schindelin
2015-10-05 21:00 ` Junio C Hamano
2015-10-06 13:17 ` [PATCH v3 0/4] Fix locking issues on Windows with `git clone --dissociate` Johannes Schindelin
2015-10-06 13:18 ` [PATCH v3 1/4] Demonstrate a Windows file locking issue " Johannes Schindelin
2015-10-06 13:18 ` [PATCH v3 2/4] Consolidate code to close a pack's file descriptor Johannes Schindelin
2015-10-06 13:18 ` [PATCH v3 3/4] Add a function to release all packs Johannes Schindelin
2015-10-07 17:49 ` Junio C Hamano
2015-10-08 19:10 ` Johannes Schindelin
2015-10-06 13:18 ` [PATCH v3 4/4] clone --dissociate: avoid locking pack files Johannes Schindelin
2015-10-11 10:45 ` [PATCH v3 0/4] Fix locking issues on Windows with `git clone --dissociate` Max Kirillov
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=20151002190646.GC26154@wheezy.local \
--to=max@max630.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).