Skip to content

Avoid commit-graph lock contention #2198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ static void am_run(struct am_state *state, int resume)
*/
if (!state->rebasing) {
am_destroy(state);
close_all_packs(the_repository->objects);
close_object_store(the_repository->objects);
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
}
}
Expand Down
2 changes: 1 addition & 1 deletion builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
transport_disconnect(transport);

if (option_dissociate) {
close_all_packs(the_repository->objects);
close_object_store(the_repository->objects);
dissociate_from_references();
}

Expand Down
2 changes: 1 addition & 1 deletion builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)

string_list_clear(&list, 0);

close_all_packs(the_repository->objects);
close_object_store(the_repository->objects);

argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
if (verbosity < 0)
Expand Down
4 changes: 2 additions & 2 deletions builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
gc_before_repack();

if (!repository_format_precious_objects) {
close_all_packs(the_repository->objects);
close_object_store(the_repository->objects);
if (run_command_v_opt(repack.argv, RUN_GIT_CMD))
die(FAILED_RUN, repack.argv[0]);

Expand Down Expand Up @@ -660,7 +660,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
report_garbage = report_pack_garbage;
reprepare_packed_git(the_repository);
if (pack_garbage.nr > 0) {
close_all_packs(the_repository->objects);
close_object_store(the_repository->objects);
clean_pack_garbage();
}

Expand Down
2 changes: 1 addition & 1 deletion builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static void finish(struct commit *head_commit,
* We ignore errors in 'gc --auto', since the
* user should see them.
*/
close_all_packs(the_repository->objects);
close_object_store(the_repository->objects);
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
}
}
Expand Down
2 changes: 1 addition & 1 deletion builtin/rebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ static int finish_rebase(struct rebase_options *opts)

delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
apply_autostash(opts);
close_all_packs(the_repository->objects);
close_object_store(the_repository->objects);
/*
* We ignore errors in 'gc --auto', since the
* user should see them.
Expand Down
2 changes: 1 addition & 1 deletion builtin/receive-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
proc.git_cmd = 1;
proc.argv = argv_gc_auto;

close_all_packs(the_repository->objects);
close_object_store(the_repository->objects);
if (!start_command(&proc)) {
if (use_sideband)
copy_to_sideband(proc.err, -1, NULL);
Expand Down
2 changes: 1 addition & 1 deletion builtin/repack.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
if (!names.nr && !po_args.quiet)
printf_ln(_("Nothing new to pack."));

close_all_packs(the_repository->objects);
close_object_store(the_repository->objects);

/*
* Ok we have prepared all new packfiles.
Expand Down
8 changes: 4 additions & 4 deletions commit-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ int generation_numbers_enabled(struct repository *r)
return !!first_generation;
}

void close_commit_graph(struct repository *r)
void close_commit_graph(struct raw_object_store *o)
{
free_commit_graph(r->objects->commit_graph);
r->objects->commit_graph = NULL;
free_commit_graph(o->commit_graph);
o->commit_graph = NULL;
}

static int bsearch_graph(struct commit_graph *g, struct object_id *oid, uint32_t *pos)
Expand Down Expand Up @@ -1049,7 +1049,7 @@ void write_commit_graph(const char *obj_dir,
stop_progress(&progress);
strbuf_release(&progress_title);

close_commit_graph(the_repository);
close_commit_graph(the_repository->objects);
finalize_hashfile(f, NULL, CSUM_HASH_IN_STREAM | CSUM_FSYNC);
commit_lock_file(&lk);

Expand Down
2 changes: 1 addition & 1 deletion commit-graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void write_commit_graph(const char *obj_dir,

int verify_commit_graph(struct repository *r, struct commit_graph *g);

void close_commit_graph(struct repository *);
void close_commit_graph(struct raw_object_store *);
void free_commit_graph(struct commit_graph *);

#endif
2 changes: 1 addition & 1 deletion object.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void raw_object_store_clear(struct raw_object_store *o)
o->loaded_alternates = 0;

INIT_LIST_HEAD(&o->packed_git_mru);
close_all_packs(o);
close_object_store(o);
o->packed_git = NULL;
}

Expand Down
5 changes: 4 additions & 1 deletion packfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "tree.h"
#include "object-store.h"
#include "midx.h"
#include "commit-graph.h"

char *odb_pack_name(struct strbuf *buf,
const unsigned char *sha1,
Expand Down Expand Up @@ -336,7 +337,7 @@ void close_pack(struct packed_git *p)
close_pack_index(p);
}

void close_all_packs(struct raw_object_store *o)
void close_object_store(struct raw_object_store *o)
{
struct packed_git *p;

Expand All @@ -350,6 +351,8 @@ void close_all_packs(struct raw_object_store *o)
close_midx(o->multi_pack_index);
o->multi_pack_index = NULL;
}

close_commit_graph(o);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion packfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ extern uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);
extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
extern void close_pack_windows(struct packed_git *);
extern void close_pack(struct packed_git *);
extern void close_all_packs(struct raw_object_store *o);
extern void close_object_store(struct raw_object_store *o);
extern void unuse_pack(struct pack_window **);
extern void clear_delta_base_cache(void);
extern struct packed_git *add_packed_git(const char *path, size_t path_len, int local);
Expand Down
2 changes: 1 addition & 1 deletion upload-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ static void deepen_by_rev_list(struct packet_writer *writer, int ac,
{
struct commit_list *result;

close_commit_graph(the_repository);
close_commit_graph(the_repository->objects);
result = get_shallow_commits_by_rev_list(ac, av, SHALLOW, NOT_SHALLOW);
send_shallow(writer, result);
free_commit_list(result);
Expand Down