From: Eric Wong <e@80x24.org>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH] server-info: do not list unlinked packs
Date: Thu, 23 May 2019 08:59:59 +0000 [thread overview]
Message-ID: <20190523085959.4q76pokx2gy6wqq7@dcvr> (raw)
In-Reply-To: <20190515214806.GA31693@sigill.intra.peff.net>
Jeff King <peff@peff.net> wrote:
> On Wed, May 15, 2019 at 08:38:39PM +0000, Eric Wong wrote:
>
> > I've also noticed objects/info/packs contains stale entries
> > after repack/gc runs on current git.
> >
> > Tried adding reprepare_packed_git before update_server_info,
> > but that didn't seem to work; so maybe something isn't cleared.
> > Might have time to investigate more this week, might not...
>
> We never delete entries from the in-memory packed_git list; a reprepare
> only adds to the list. You'd need to teach update_server_info() to
> ignore packs which are no longer present (or switch to exec-ing a
> separate update-server-info binary).
Ah, checking files_exists() and setting a bit seems sufficient.
--------8<---------
Subject: [PATCH] server-info: do not list unlinked packs
Having non-existent packs in objects/info/packs causes
dumb HTTP clients to abort.
There remains a small window where the old objects/info/packs
file can refer to unlinked packs. That's unavoidable even on a
local FS given the time-of-use-time-of-check window between
listing and retrieving files.
Signed-off-by: Eric Wong <e@80x24.org>
---
I think the small window I refer to can be worked around by
teaching the dumb HTTP client to reread objects/info/packs
if it 404s while trying to GET a pack...
object-store.h | 1 +
server-info.c | 7 ++++++-
t/t6500-gc.sh | 2 ++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/object-store.h b/object-store.h
index 272e01e452..2c9facc8f2 100644
--- a/object-store.h
+++ b/object-store.h
@@ -77,6 +77,7 @@ struct packed_git {
freshened:1,
do_not_close:1,
pack_promisor:1,
+ pack_unlinked:1,
multi_pack_index:1;
unsigned char hash[GIT_MAX_RAWSZ];
struct revindex_entry *revindex;
diff --git a/server-info.c b/server-info.c
index 41274d098b..69e2c5279b 100644
--- a/server-info.c
+++ b/server-info.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "dir.h"
#include "repository.h"
#include "refs.h"
#include "object.h"
@@ -199,12 +200,16 @@ static void init_pack_info(const char *infofile, int force)
*/
if (!p->pack_local)
continue;
+ if (!file_exists(p->pack_name)) {
+ p->pack_unlinked = 1;
+ continue;
+ }
i++;
}
num_pack = i;
info = xcalloc(num_pack, sizeof(struct pack_info *));
for (i = 0, p = get_all_packs(the_repository); p; p = p->next) {
- if (!p->pack_local)
+ if (!p->pack_local || p->pack_unlinked)
continue;
assert(i < num_pack);
info[i] = xcalloc(1, sizeof(struct pack_info));
diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
index 515c6735e9..c0f04dc6b0 100755
--- a/t/t6500-gc.sh
+++ b/t/t6500-gc.sh
@@ -71,6 +71,8 @@ test_expect_success 'gc --keep-largest-pack' '
git gc --keep-largest-pack &&
( cd .git/objects/pack && ls *.pack ) >pack-list &&
test_line_count = 2 pack-list &&
+ awk "/^P /{print \$2}" <.git/objects/info/packs >pack-info &&
+ test_line_count = 2 pack-info &&
test_path_is_file $BASE_PACK &&
git fsck
)
base-commit: aa25c82427ae70aebf3b8f970f2afd54e9a2a8c6
--
EW
next prev parent reply other threads:[~2019-05-23 9:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-11 1:34 [PATCH] update-server-info: avoid needless overwrites Eric Wong
2019-05-11 7:35 ` Eric Sunshine
2019-05-11 20:47 ` [PATCH v2] " Eric Wong
2019-05-11 21:17 ` [PATCH] " Eric Wong
2019-05-11 23:37 ` Ævar Arnfjörð Bjarmason
2019-05-12 0:38 ` Eric Wong
2019-05-12 4:08 ` Jeff King
2019-05-12 7:16 ` Ævar Arnfjörð Bjarmason
2019-05-14 9:47 ` Jeff King
2019-05-14 10:33 ` Ævar Arnfjörð Bjarmason
2019-05-14 11:24 ` Jeff King
2019-05-14 11:57 ` Ævar Arnfjörð Bjarmason
2019-05-14 11:50 ` Eric Wong
2019-05-14 12:13 ` dumb HTTP things I want to do Eric Wong
2019-05-14 12:27 ` Jeff King
2019-05-14 12:19 ` [PATCH] update-server-info: avoid needless overwrites Ævar Arnfjörð Bjarmason
2019-05-14 12:29 ` Jeff King
2019-05-15 0:45 ` [PATCH 2/1] server-info: conditionally update on fetch Eric Wong
2019-05-15 20:38 ` [WIP] repack leaving stale entries in objects/info/packs Eric Wong
2019-05-15 21:48 ` Jeff King
2019-05-23 8:59 ` Eric Wong [this message]
2019-05-23 10:24 ` [PATCH] server-info: do not list unlinked packs Jeff King
2019-05-23 17:27 ` [PATCH v2] " Eric Wong
2019-05-24 6:05 ` Jeff King
2019-05-24 7:34 ` Ævar Arnfjörð Bjarmason
2019-05-13 23:17 ` [PATCH v3] update-server-info: avoid needless overwrites Eric Wong
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190523085959.4q76pokx2gy6wqq7@dcvr \
--to=e@80x24.org \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).