repack: respect gc.pid lock
Subsystems (2)
PATCH 1/1 repack: respect gc.pid lock
Git gc locks the repository (using a gc.pid file) so that other gcs don't run concurrently. Make git repack respect this lock.
Now repack, by default, will refuse to run at the same time as a gc. This fixes a concurrency issue: a repack which deleted packs would make a concurrent gc sad when its packs were deleted out from under it. The gc would fail with: "fatal: ./objects/pack/pack-$sha.pack cannot be accessed". Then it would die, probably leaving a large temp pack hanging around.
Git repack learns --no-lock, so that when run under git gc, it doesn't attempt to manage the lock itself.
Martin Fick suggested just moving the lock into git repack, but this would leave parts of git gc (e.g. git prune) protected by only local locks. I worried that a prune (part of git gc) concurrent with a repack could confuse the repack, so I decided to go with this solution.
--- Documentation/git-repack.txt | 5 +++ Makefile | 1 + builtin/gc.c | 72 ++---------------------------------- builtin/repack.c | 13 +++++++ repack.c | 88 ++++++++++++++++++++++++++++++++++++++++++++ repack.h | 8 ++++ t/t7700-repack.sh | 8 ++++ 7 files changed, 127 insertions(+), 68 deletions(-) create mode 100644 repack.c create mode 100644 repack.h
Documentation/git-repack.txt +5 -0
@@ -143,6 +143,11 @@ other objects in that pack they already have locally. being removed. In addition, any unreachable loose objects will be packed (and their loose counterparts removed). +--no-lock:: + Do not lock the repository, and do not respect any existing lock. + Mostly useful for running repack within git gc. Do not use this + unless you know what you are doing. + Configuration -------------
Makefile +1 -0
@@ -816,6 +816,7 @@ LIB_OBJS += refs/files-backend.o LIB_OBJS += refs/iterator.o LIB_OBJS += ref-filter.o LIB_OBJS += remote.o +LIB_OBJS += repack.o LIB_OBJS += replace_object.o LIB_OBJS += rerere.o LIB_OBJS += resolve-undo.o
builtin/gc.c +4 -68
105 lines not on this page · raw message
builtin/repack.c +13 -0
@@ -7,6 +7,7 @@#include "strbuf.h" #include "string-list.h" #include "argv-array.h" +#include "repack.h" static int delta_base_offset =1 ;static int pack_kept_objects =-1 ;
@@ -160,6 +161,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)int no_update_server_info =0 ;int quiet =0 ;int local =0 ; +int no_lock =0 ;struct option builtin_repack_options[] = { OPT_BIT('a', NULL, &pack_everything,
@@ -194,6 +196,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix) N_("maximum size of each packfile")),OPT_BOOL (0 ,"pack-kept-objects" , &pack_kept_objects,N_ ("repack objects in packs marked with .keep" )), +OPT_BOOL (0 ,"no-lock" , &no_lock, +N_ ("Do not lock the repository, and do not respect any existing lock. Mostly useful for operation within git gc." )), OPT_END() };
@@ -215,6 +219,15 @@ int cmd_repack(int argc, const char **argv, const char *prefix)if (write_bitmaps && !(pack_everything &ALL_INTO_ONE ))die (_ (incremental_bitmap_conflict_error)); +if (!no_lock) { +pid_t pid; +const char *name =lock_repo_for_pack_manipulation (0 , &pid); +if (name) { +die (_ ("pack operation (gc or repack) is already running on machine '%s' pid %" PRIuMAX" (use --no-lock if not)" ), + name, (uintmax_t )pid); + } + } + packdir =mkpathdup ("%s/pack" ,get_object_directory ()); packtmp =mkpathdup ("%s/.tmp-%d-pack" , packdir, (int )getpid ());
repack.c new file +88 -0
88 lines not on this page · raw message
repack.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef REPACK_H +#define REPACK_H + +#include "git-compat-util.h" + +const char *lock_repo_for_pack_manipulation (int force,pid_t * ret_pid); + +#endif /* REPACK_H */
t/t7700-repack.sh +8 -0
@@ -196,5 +196,13 @@ test_expect_success 'objects made unreachable by grafts only are kept' ' git cat-file -t $H1 ' +test_expect_success 'repack respects gc.pid' ' + test_tick && + test_when_finished "rm -f .git/gc.pid" && + echo -n "1234 hostname" >.git/gc.pid && + test_must_fail git repack -a -d 2>err && + test_i18ngrep "already running on machine .hostname. pid 1234" err + ' + test_done
Signature · 1 line
2.11.GIT
Quoted 10 lines · David Turner
Git gc locks the repository (using a gc.pid file) so that other gcs don't run concurrently. Make git repack respect this lock.
Now repack, by default, will refuse to run at the same time as a gc. This fixes a concurrency issue: a repack which deleted packs would make a concurrent gc sad when its packs were deleted out from under it. The gc would fail with: "fatal: ./objects/pack/pack-$sha.pack cannot be accessed". Then it would die, probably leaving a large temp pack hanging around.
Quoted 9 lines
Git repack learns --no-lock, so that when run under git gc, it doesn't attempt to manage the lock itself.
Martin Fick suggested just moving the lock into git repack, but this would leave parts of git gc (e.g. git prune) protected by only local locks. I worried that a prune (part of git gc) concurrent with a repack could confuse the repack, so I decided to go with this solution.
The last paragraph could be reworded to be a bit less personal and more as a direct statement of why moving the lock entirely to repack is a bad idea.
Quoted 18 lines
Signed-off-by David Turner <[email protected]>--- Documentation/git-repack.txt | 5 +++ Makefile | 1 + builtin/gc.c | 72 ++---------------------------------- builtin/repack.c | 13 +++++++ repack.c | 88 ++++++++++++++++++++++++++++++++++++++++++++ repack.h | 8 ++++ t/t7700-repack.sh | 8 ++++ 7 files changed, 127 insertions(+), 68 deletions(-) create mode 100644 repack.c create mode 100644 repack.hDocumentation/git-repack.txt +0
-0
Documentation/git-repack.txt other objects in that pack they already have locally. · line 150
Quoted 8 lines
Documentation/git-repack.txt +5
-0@@ -143,6 +143,11 @@ other objects in that pack they already have locally. being removed. In addition, any unreachable loose objects will be packed (and their loose counterparts removed). +--no-lock:: + Do not lock the repository, and do not respect any existing lock. + Mostly useful for running repack within git gc. Do not use this + unless you know what you are doing. +
I would have phrased this more like:
Used internally by git gc to call git repack while already holding
the lock. Do not use unless you know what you're doing.
Quoted 10 lines · David Turner
Git gc locks the repository (using a gc.pid file) so that other gcs don't run concurrently. Make git repack respect this lock.
Now repack, by default, will refuse to run at the same time as a gc. This fixes a concurrency issue: a repack which deleted packs would make a concurrent gc sad when its packs were deleted out from under it. The gc would fail with: "fatal: ./objects/pack/pack-$sha.pack cannot be accessed". Then it would die, probably leaving a large temp pack hanging around.
Quoted 2 lines
Git repack learns --no-lock, so that when run under git gc, it doesn't attempt to manage the lock itself.
This also means that two repack invocations cannot run simultaneously, because they want to take the same lock. But depending on the options, the two don't necessarily conflict. For example, two simultaneous incremental "git repack -d" invocations should be able to complete.
Do we know where the error message is coming from? I couldn't find the error message you've given above; grepping for "cannot be accessed" shows only error messages that would have "packfile" after the "fatal:". Is it a copy-paste error?
If that's the case, then it's the one in use_pack(). Do we know what program/operation is causing the error? Having a simultaneous gc delete a packfile is _supposed_ to work, through a combination of:
1. Most sha1-access operations can re-scan the pack directory if they find the packfile went away.
2. The pack-objects run by a simultaneous repack is somewhat special in that once it finds and commits to a copy of an object in a pack, we need to use exactly that pack, because we record its offset, delta representation, etc. Usually this works because we open and mmap the packfile before making that commitment, and open packfiles are only closed if you run out of file descriptors (which should only happen when you have a huge number of packs).
So I'm worried that this repack lock is going to regress some other cases that run fine together. But I'm also worried that it's a band-aid over a more subtle problem. If pack-objects is not able to run alongside a gc, then you're also going to have problems serving fetches, and obviously you wouldn't want to take a lock there.
-Peff
Quoted 29 lines
-----Original Message-----
From: Jeff King [mailto:[email protected]]
Sent: Friday, April 14, 2017 3:34 PM
To: David Turner <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] repack: respect gc.pid lockQuoted 10 lines · David Turner
Git gc locks the repository (using a gc.pid file) so that other gcs don't run concurrently. Make git repack respect this lock.
Now repack, by default, will refuse to run at the same time as a gc. This fixes a concurrency issue: a repack which deleted packs would make a concurrent gc sad when its packs were deleted out from under it. The gc would fail with: "fatal: ./objects/pack/pack-$sha.pack cannot be accessed". Then it would die, probably leaving a large temp pack hanging around.
Quoted 2 lines
Git repack learns --no-lock, so that when run under git gc, it doesn't attempt to manage the lock itself.
This also means that two repack invocations cannot run simultaneously, because they want to take the same lock. But depending on the options, the two don't necessarily conflict. For example, two simultaneous incremental "git repack -d" invocations should be able to complete.
Quoted 4 lines
Do we know where the error message is coming from? I couldn't find the error message you've given above; grepping for "cannot be accessed" shows only error messages that would have "packfile" after the "fatal:". Is it a copy-paste error?
Yes, it is. Sorry.
We saw this failure in the logs multiple times (with three different
shas, while a gc was running):
April 12, 2017 06:45 -> ERROR -> 'git -c repack.writeBitmaps=true repack -A -d --pack-kept-objects' in [repo] failed:
fatal: packfile ./objects/pack/pack-[sha].pack cannot be accessed
Possibly some other repack was also running at the time as well.
My colleague also saw it while manually doing gc (again while repacks were likely to be running):
$ git gc --aggressive Counting objects: 13800073, done. Delta compression using up to 8 threads. Compressing objects: 99% (11465846/11465971) Compressing objects: 100% (11465971/11465971), done. fatal: packfile [repo]/objects/pack/pack-[sha].pack cannot be accessed
(yes, I know that --aggressive is usually not desirable)
Quoted 7 lines
If that's the case, then it's the one in
use_pack(). Do we know what program/operation is causing the error? Having a simultaneous gc delete a packfile is _supposed_ to work, through a combination of:1. Most sha1-access operations can re-scan the pack directory if they find the packfile went away.
Quoted 7 lines
2. The pack-objects run by a simultaneous repack is somewhat special in that once it finds and commits to a copy of an object in a pack, we need to use exactly that pack, because we record its offset, delta representation, etc. Usually this works because we open and mmap the packfile before making that commitment, and open packfiles are only closed if you run out of file descriptors (which should only happen when you have a huge number of packs).
We have a reasonable rlimit (64k soft limit), so that failure mode is pretty unlikely. I think we should have had 20 or so packs -- not tens of thousands.
Quoted 5 lines
So I'm worried that this repack lock is going to regress some other cases that run fine together. But I'm also worried that it's a band-aid over a more subtle problem. If pack-objects is not able to run alongside a gc, then you're also going to have problems serving fetches, and obviously you wouldn't want to take a lock there.
I see your point. I don't know if it's pack-objects that's seeing this, although maybe that's the only reasonable codepath.
I did some tracing through the code, and couldn't figure out how to trigger that error message. It appears in two places in the code, but only when the pack is not initialized. But the packs always seem to be set up by that point in my test runs. It's worth noting that I'm not testing on the gitlab server; I'm testing on my laptop with a completely different repo. But I've tried various ways to repro this -- or even to get to a point where those errors would have been thrown given a missing pack -- and I have not been able to.
Do you have any idea why this would be happening other than the rlimit thing?
Quoted 8 lines · David Turner
We saw this failure in the logs multiple times (with three different
shas, while a gc was running):
April 12, 2017 06:45 -> ERROR -> 'git -c repack.writeBitmaps=true repack -A -d --pack-kept-objects' in [repo] failed:
fatal: packfile ./objects/pack/pack-[sha].pack cannot be accessed
Possibly some other repack was also running at the time as well.My colleague also saw it while manually doing gc (again while repacks were likely to be running):
This is sort of a side question, but...why are you running other repacks alongside git-gc? It seems like you ought to be doing one or the other.
I don't begrudge anybody with a complicated setup running their own set of gc commands, but I'd think you would want to do locking there, and disable auto-gc entirely. Otherwise you're going to get different results depending on who gc'd last.
Quoted 6 lines
$ git gc --aggressive Counting objects: 13800073, done. Delta compression using up to 8 threads. Compressing objects: 99% (11465846/11465971) Compressing objects: 100% (11465971/11465971), done. fatal: packfile [repo]/objects/pack/pack-[sha].pack cannot be accessed
OK, so this presumably happened during the writing phase. Which seems like the "a pack was closed, and we couldn't re-open it" problem we've seen before.
Quoted 4 lines
We have a reasonable rlimit (64k soft limit), so that failure mode is pretty unlikely. I think we should have had 20 or so packs -- not tens of thousands. [...]
Do you have any idea why this would be happening other than the rlimit thing?
Yeah, that should be enough (you could double check the return of get_max_fd_limit() on your system if you wanted to be paranoid).
We also keep only a limited number of bytes mmap'd at one time. Normally we don't actually close packfiles when we release their mmap windows. But I think there is one path that might. When use_pack() maps a pack, if the entire pack fits in a single window, then we close it; this is due to d131b7afe (sha1_file.c: Don't retain open fds on small packs, 2011-03-02).
But if we ever unmap that window, now we have no handle to the pack. Normally on a 64-bit system this wouldn't happen at all, since the default core.packedGitLimit is 8GB there.
So if you have a few small packs and one very large pack (over 8GB), I think this could trigger. We may do the small-pack thing for some of them, and then the large pack forces us to drop the mmaps for some of the others. When we go back to access the small pack, we find it's gone.
One solution would be to bump core.packedGitLimit to something much higher (it's an mmap, so we're really just chewing up address space; it's up to the OS to decide when to load pages from disk and when to drop them).
The other alternative is to disable the small-pack closing from d131b7afe. It might need to be configurable, or perhaps auto-tuned based on the fd limit. Linux systems tend to have generous descriptor limits, but I'm not sure we can rely on that. OTOH, it seems like the code to close descriptors when needed would take care of things. So maybe we should just revert d131b7afe entirely.
The final thing I'd ask is whether you might be on a networked filesystem that would foil our usual "open descriptors mean packs don't go away" logic. But after having dug into the details above, I have a feeling the answer is simply that you have repositories >8GB.
And if that is the case, then yeah, your locking patch is definitely a band-aid. If you fetch and repack at the same time, you'll eventually see a racy failed fetch.
-Peff
Quoted 20 lines
-----Original Message-----
From: Jeff King [mailto:[email protected]]
Sent: Monday, April 17, 2017 11:42 PM
To: David Turner <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] repack: respect gc.pid lockQuoted 3 lines · David Turner
We saw this failure in the logs multiple times (with three different shas, while a gc was running):
April 12, 2017 06:45 -> ERROR -> 'git -c repack.writeBitmaps=true repack -A -d--pack-kept-objects' in [repo] failed:
Quoted 5 lines
fatal: packfile ./objects/pack/pack-[sha].pack cannot be accessed Possibly some other repack was also running at the time as well.
My colleague also saw it while manually doing gc (again while repacks were likely to be running):
Quoted 7 lines
This is sort of a side question, but...why are you running other repacks alongside git-gc? It seems like you ought to be doing one or the other.
I don't begrudge anybody with a complicated setup running their own set of gc commands, but I'd think you would want to do locking there, and disable auto- gc entirely. Otherwise you're going to get different results depending on who gc'd last.
That's what gitlab does, so you'll have to ask them why they do it that way. From https://gitlab.com/gitlab-org/gitlab-ce/issues/30939#note_27487981
it looks like they may have intended to have a lock but not quite succeeded.
Quoted 25 lines
Quoted 6 lines
$ git gc --aggressive Counting objects: 13800073, done. Delta compression using up to 8 threads. Compressing objects: 99% (11465846/11465971) Compressing objects: 100% (11465971/11465971), done. fatal: packfile [repo]/objects/pack/pack-[sha].pack cannot be accessedOK, so this presumably happened during the writing phase. Which seems like the "a pack was closed, and we couldn't re-open it" problem we've seen before.
Quoted 2 lines
We have a reasonable rlimit (64k soft limit), so that failure mode is pretty unlikely. I think we should have had 20 or so packs -- not tens of
thousands.
Quoted 2 lines
[...]
Do you have any idea why this would be happening other than the rlimit thing?Yeah, that should be enough (you could double check the return of
get_max_fd_limit()on your system if you wanted to be paranoid).We also keep only a limited number of bytes mmap'd at one time. Normally we don't actually close packfiles when we release their mmap windows. But I think there is one path that might. When
use_pack()maps a pack, if the entire pack fits in a single window, then we close it; this is due tod131b7afe(sha1_file.c: Don't retain open fds on small packs, 2011-03-02).
Quoted 3 lines
But if we ever unmap that window, now we have no handle to the pack. Normally on a 64-bit system this wouldn't happen at all, since the default core.packedGitLimit is 8GB there.
Aha, I missed that limit while messing around with the code. That must be it.
Quoted 9 lines
So if you have a few small packs and one very large pack (over 8GB), I think this could trigger. We may do the small-pack thing for some of them, and then the large pack forces us to drop the mmaps for some of the others. When we go back to access the small pack, we find it's gone.
One solution would be to bump core.packedGitLimit to something much higher (it's an mmap, so we're really just chewing up address space; it's up to the OS to decide when to load pages from disk and when to drop them).
Quoted 5 lines
The other alternative is to disable the small-pack closing from
d131b7afe. It might need to be configurable, or perhaps auto-tuned based on the fd limit. Linux systems tend to have generous descriptor limits, but I'm not sure we can rely on that. OTOH, it seems like the code to close descriptors when needed would take care of things. So maybe we should just revertd131b7afeentirely.
I definitely remember running into fd limits when processing very large numbers of packs at Twitter, but I don't recall the exact details. Presumably, d131b7afe was supposed to help with this, but in fact, it did not totally solve it. Perhaps we were doing something funny. Adjusting the fd limits was the easy fix.
On 64-bit systems, I think core.packedGitLimit doesn't make a lot of sense. There is plenty of address space. Why not use it?
For 32-bit systems, of course, address space is more precious.
I'll ask our git server administrator to adjust core.packedGitLimit and turn repacks back on to see if that fixes the issue.
Quoted 4 lines
The final thing I'd ask is whether you might be on a networked filesystem that would foil our usual "open descriptors mean packs don't go away" logic. But after having dug into the details above, I have a feeling the answer is simply that you have repositories >8GB.
Yes, our repo is >8GB, and no, it's not on a networked filesystem.
Quoted 2 lines
And if that is the case, then yeah, your locking patch is definitely a band-aid. If you fetch and repack at the same time, you'll eventually see a racy failed fetch.
Fair enough.
Quoted 2 lines · David Turner
On 64-bit systems, I think core.packedGitLimit doesn't make a lot of sense. There is plenty of address space. Why not use it?
That's my gut feeling, too. I'd have a slight worry that the OS's paging behavior may respond differently if we have more memory mapped. But that's not based on numbers, just a fear of the unknown. :)
If we have infinite windows anyway, I suspect we could just mmap entire packfiles and forget about all the window complexity in the first place. Although IIRC some operating systems take a long time to set up large mmaps, and we may only need a small part of a large pack.
Quoted 2 lines
I'll ask our git server administrator to adjust core.packedGitLimit and turn repacks back on to see if that fixes the issue.
Thanks. Let us know if you get any results, either way.
-Peff
Quoted 14 lines
-----Original Message-----
From: Jeff King [mailto:[email protected]]
Sent: Monday, April 17, 2017 11:42 PM
To: David Turner <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] repack: respect gc.pid lockQuoted 3 lines · David Turner
We saw this failure in the logs multiple times (with three different shas, while a gc was running):
April 12, 2017 06:45 -> ERROR -> 'git -c repack.writeBitmaps=true repack -A -d--pack-kept-objects' in [repo] failed:
Quoted 8 lines
Quoted 5 lines
fatal: packfile ./objects/pack/pack-[sha].pack cannot be accessed Possibly some other repack was also running at the time as well.
My colleague also saw it while manually doing gc (again while repacks were likely to be running):
This is sort of a side question, but...why are you running other repacks alongside git-gc? It seems like you ought to be doing one or the other.
But actually, it would be kind of nice if git would help protect us from doing this?
Quoted 17 lines · David Turner
Quoted 17 lines
-----Original Message-----
From: Jeff King [mailto:[email protected]]
Sent: Monday, April 17, 2017 11:42 PM
To: David Turner <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] repack: respect gc.pid lockQuoted 3 lines · David Turner
We saw this failure in the logs multiple times (with three different shas, while a gc was running):
April 12, 2017 06:45 -> ERROR -> 'git -c repack.writeBitmaps=true repack -A -d--pack-kept-objects' in [repo] failed:
Quoted 3 lines
fatal: packfile ./objects/pack/pack-[sha].pack cannot be accessed Possibly some other repack was also running at the time as well.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
My colleague also saw it while manually doing gc (again while repacks were likely to be running):
This is sort of a side question, but...why are you running other repacks alongside git-gc? It seems like you ought to be doing one or the other.
But actually, it would be kind of nice if git would help protect us from doing this?
A lock can catch the racy cases where both run at the same time. But I think that even:
git -c repack.writeBitmaps=true repack -Ad
[...wait...]
git gc
is questionable, because that gc will erase your bitmaps. How does git-gc know that it's doing a bad thing by repacking without bitmaps, and that you didn't simply change your configuration or want to get rid of them?
-Peff
Quoted 43 lines
-----Original Message-----
From: Jeff King [mailto:[email protected]]
Sent: Tuesday, April 18, 2017 1:20 PM
To: David Turner <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] repack: respect gc.pid lockQuoted 15 lines · David Turner
Quoted 15 lines
-----Original Message-----
From: Jeff King [mailto:[email protected]]
Sent: Monday, April 17, 2017 11:42 PM
To: David Turner <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] repack: respect gc.pid lockQuoted 4 lines · David Turner
We saw this failure in the logs multiple times (with three different shas, while a gc was running):
April 12, 2017 06:45 -> ERROR -> 'git -c repack.writeBitmaps=true repack -A -d--pack-kept-objects' in [repo] failed:
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
fatal: packfile ./objects/pack/pack-[sha].pack cannot be accessed Possibly some other repack was also running at the time as well.
My colleague also saw it while manually doing gc (again while repacks were likely to be running):
This is sort of a side question, but...why are you running other repacks alongside git-gc? It seems like you ought to be doing one or the
other.
Quoted 2 lines
But actually, it would be kind of nice if git would help protect us from doing
this?
A lock can catch the racy cases where both run at the same time. But I think that even:
Quoted 7 lines
git -c repack.writeBitmaps=true repack -Ad
[...wait...]
git gcis questionable, because that gc will erase your bitmaps. How does git-gc know that it's doing a bad thing by repacking without bitmaps, and that you didn't simply change your configuration or want to get rid of them?
Sorry, the gc in Gitlab does keep bitmaps. The one I quoted in a previous message doesn't, because the person typing the command was just doing some manual testing and I guess didn't realize that bitmaps were important. Or perhaps he knew that repack.writeBitmaps was already set in the config.
So given that the lock will catch the races, might it be a good idea (if Implemented to avoid locking on repack -d)?
Quoted 7 lines · David Turner
Quoted 7 lines
A lock can catch the racy cases where both run at the same time. But I think that even:
git -c repack.writeBitmaps=true repack -Ad
[...wait...]
git gc
Quoted 8 lines
Quoted 3 lines
is questionable, because that gc will erase your bitmaps. How does git-gc know that it's doing a bad thing by repacking without bitmaps, and that you didn't simply change your configuration or want to get rid of them?
Sorry, the gc in Gitlab does keep bitmaps. The one I quoted in a previous message doesn't, because the person typing the command was just doing some manual testing and I guess didn't realize that bitmaps were important. Or perhaps he knew that repack.writeBitmaps was already set in the config.
Sure, but I guess I'd just wonder what _else_ is different between the commands (and if nothing, why are both running).
Quoted 2 lines
So given that the lock will catch the races, might it be a good idea (if Implemented to avoid locking on repack -d)?
I'm mildly negative just because it increases complexity, and I don't think it's actually buying very much. It's not clear to me which invocations of repack would want to lock and which ones wouldn't.
Is "-a" or "-A" the key factor? Are there current callers who prefer the current behavior of "possibly duplicate some work, but never report failure" versus "do not duplicate work, but sometimes fail due to lock contention"?
-Peff
Quoted 23 lines
-----Original Message-----
From: Jeff King [mailto:[email protected]]
Sent: Tuesday, April 18, 2017 1:50 PM
To: David Turner <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] repack: respect gc.pid lockQuoted 11 lines · David Turner
Quoted 11 lines
A lock can catch the racy cases where both run at the same time. But I think that
even:git -c repack.writeBitmaps=true repack -Ad
[...wait...]
git gcis questionable, because that gc will erase your bitmaps. How does git-gc know that it's doing a bad thing by repacking without bitmaps, and that you didn't simply change your configuration or want to get
rid of them?
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Sorry, the gc in Gitlab does keep bitmaps. The one I quoted in a previous message doesn't, because the person typing the command was just doing some manual testing and I guess didn't realize that bitmaps were important. Or perhaps he knew that repack.writeBitmaps was
already set in the config.
Sure, but I guess I'd just wonder what _else_ is different between the commands (and if nothing, why are both running).
Presumably, repack is faster, and they're not intended to run concurrently (but there's a Gitlab bug causing them to do so). But you'll have to ask the Gitlab folks for more details.
Quoted 10 lines
Quoted 2 lines
So given that the lock will catch the races, might it be a good idea (if Implemented to avoid locking on repack -d)?
I'm mildly negative just because it increases complexity, and I don't think it's actually buying very much. It's not clear to me which invocations of repack would want to lock and which ones wouldn't.
Is "-a" or "-A" the key factor? Are there current callers who prefer the current behavior of "possibly duplicate some work, but never report failure" versus "do not duplicate work, but sometimes fail due to lock contention"?
One problem with failing is that it can leave a temp pack behind.
I think the correct fix is to change the default code.packedGitLimit on 64-bit machines to 32 terabytes (2**45 bytes). That's because on modern Intel processors, there are 48 bits of address space actually available, but the kernel is going to probably reserve a few bits. My machine claims to have 2**46 bytes of virtual address space available. It's also several times bigger than any repo that I know of or can easily imagine.
Does that seem reasonable to you?
Quoted 5 lines · David Turner
Quoted 3 lines
Is "-a" or "-A" the key factor? Are there current callers who prefer the current behavior of "possibly duplicate some work, but never report failure" versus "do not duplicate work, but sometimes fail due to lock contention"?
One problem with failing is that it can leave a temp pack behind.
Yeah. IMHO we should probably treat failed object and pack writes as normal tempfiles and remove them (but possibly respect a "debug mode" that leaves them around). But that's another patch entirely.
Quoted 8 lines
I think the correct fix is to change the default code.packedGitLimit on 64-bit machines to 32 terabytes (2**45 bytes). That's because on modern Intel processors, there are 48 bits of address space actually available, but the kernel is going to probably reserve a few bits. My machine claims to have 2**46 bytes of virtual address space available. It's also several times bigger than any repo that I know of or can easily imagine.
Does that seem reasonable to you?
Yes, it does.
-Peff