Skip to content

Commit

Permalink
midx: disable replace objects
Browse files Browse the repository at this point in the history
We observed a series of clone failures arose in a specific set of
repositories after we fully enabled the MIDX bitmap feature within our
Codebase service. These failures were accompanied with error messages
such as:

  fatal: did not receive expected object ...
  fatal: fetch-pack: invalid index-pack output

Temporarily disabling the MIDX feature eliminated the reported issues.
After some investigation we found that all repositories experiencing
failures containe replace references, which seem to be improperly
acknowledged by the MIDX bitmap logic. Indeed, this issue appears to
have persisted since the introduction of MIDX.

This patch updates the MIDX logic to disable replace objects during
operations, mirroring the handling seen in single pack index scenarios,
ie git-index-pack and git-pack-objects.

Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
  • Loading branch information
blanet committed Apr 7, 2024
1 parent 3c2a3fd commit 1def36a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin/multi-pack-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "strbuf.h"
#include "trace2.h"
#include "object-store-ll.h"
#include "replace-object.h"

#define BUILTIN_MIDX_WRITE_USAGE \
N_("git multi-pack-index [<options>] write [--preferred-pack=<pack>]" \
Expand Down Expand Up @@ -273,6 +274,8 @@ int cmd_multi_pack_index(int argc, const char **argv,
};
struct option *options = parse_options_concat(builtin_multi_pack_index_options, common_opts);

disable_replace_refs();

git_config(git_default_config, NULL);

if (the_repository &&
Expand Down
23 changes: 23 additions & 0 deletions t/t5326-multi-pack-bitmaps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,29 @@ test_expect_success 'tagged commits are selected for bitmapping' '
)
'

test_expect_success 'replace objects are ignored by MIDX bitmap' '
rm -fr repo &&
git init repo &&
test_when_finished "rm -fr repo" &&
(
cd repo &&
test_commit A &&
A=$(git rev-parse HEAD) &&
test_commit B &&
B=$(git rev-parse HEAD) &&
git checkout --orphan=orphan $A &&
test_commit orphan &&
C=$(git rev-parse HEAD) &&
git repack -ad &&
git rev-list --objects --no-object-names $B |sort >expected &&
git replace $A $C &&
git multi-pack-index write --bitmap &&
git rev-list --objects --no-object-names --use-bitmap-index $B |sort >actual &&
test_cmp expected actual
)
'

corrupt_file () {
chmod a+w "$1" &&
printf "bogus" | dd of="$1" bs=1 seek="12" conv=notrunc
Expand Down

0 comments on commit 1def36a

Please sign in to comment.