git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] packfile: close multi-pack-index in close_all_packs

From
Derrick Stolee <stolee@gmail.com>
Date
Oct 25, 2018, 12:54 UTC
Message-ID
<20181025125405.30351-1-dstolee@microsoft.com>
In-Reply-To
<20181025111557.GL30222@szeder.dev>

Whenever we delete pack-files from the object directory, we need to also delete the multi-pack-index that may refer to those objects. Sometimes, this connection is obvious, like during a repack. Other times, this is less obvious, like when gc calls a repack command and then does other actions on the objects, like write a commit-graph file.

The pattern we use to avoid out-of-date in-memory packed_git structs is to call close_all_packs(). This should also call close_midx(). Since we already pass an object store to close_all_packs(), this is a nicely scoped operation.

This fixes a test failure when running t6500-gc.sh with GIT_TEST_MULTI_PACK_INDEX=1.

Reported-by: Szeder Gábor <szeder.dev@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---

Thanks for the report, Szeder! I think this is the correct fix, and more likely to be permanent across all builtins that run auto-GC. I based it on ds/test-multi-pack-index so it could easily be added on top.

-Stolee
 packfile.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/packfile.c b/packfile.c
index 841b36182f..37fcd8f136 100644
--- a/packfile.c
+++ b/packfile.c
@@ -339,6 +339,11 @@ void close_all_packs(struct raw_object_store *o)
 			BUG("want to close pack marked 'do-not-close'");
 		else
 			close_pack(p);
+
+	if (o->multi_pack_index) {
+		close_midx(o->multi_pack_index);
+		o->multi_pack_index = NULL;
+	}
 }
 
 /*

base-commit: 0465a50506023df0932fe0534fe6ac6712c0d854
-- 
2.17.1
Previous: SZEDER GáborNext: SZEDER Gábor
Message 2 of 6 in “'ds/test-multi-pack-index' vs. 'ab/commit-graph-progress'”
  1. SZEDER GáborOct 25, 2018
  2. packfile: close multi-pack-index in close_all_packsDerrick Stolee, Oct 25, 2018
  3. SZEDER GáborOct 29, 2018
  4. Derrick StoleeOct 29, 2018
  5. Ævar Arnfjörð BjarmasonOct 25, 2018
  6. SZEDER GáborOct 29, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.