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

[FYI] commit-graph: trace expiry of commit graph links

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Jul 16, 2020, 22:57 UTC
Message-ID
<20200716225725.4143039-1-jonathantanmy@google.com>
In-Reply-To
<92b218ca-f2b4-db9d-9f9c-1d071ea4fa97@gmail.com>

When an obsolete link in the commit graph chain is deleted, and trace2 is enabled, trace a message that it is deleted, along with the list of links before and after the current chain refresh.

The messages are emitted using trace2_data_string() and not trace2_printf() because the latter is not implemented for some trace targets.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
This patch is just for informational purposes for people who have the
same problem and/or want to help diagnose.
I've tested that this produces the expected trace2 messages using:
  git commit-graph write --reachable --split=replace
> It is _possible_ that something like a case switch or a symlink
> could be causing a problem here. That's where I would look on
> the affected systems.

Indeed a symlink is present - the affected repositories are using the git-repo [1] local mirror feature, which causes .git/objects (among other things) to be a symlink - but I couldn't figure out how this symlink would cause problems. In particular, looking at the code, all relevant filenames seem to be constructed from ctx->odb->path, so no matter which names were used to get to the object directory, all names are built from those names, and this seems to be true in practice as well.

So I've added some trace2 messages (in this patch), and let's see if I can figure out what's going on. I'll write back if I find something.

[1] https://gerrit.googlesource.com/git-repo
---
 commit-graph.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/commit-graph.c b/commit-graph.c
index 328ab06fd4..b5bd2ac6de 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2009,6 +2009,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
 	struct dirent *de;
 	size_t dirnamelen;
 	timestamp_t expire_time = time(NULL);
+	int commit_graph_deleted = 0;
 
 	if (ctx->split_opts && ctx->split_opts->expire_time)
 		expire_time = ctx->split_opts->expire_time;
@@ -2050,8 +2051,38 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
 			}
 		}
 
-		if (!found)
+		if (!found) {
+			if (trace2_is_enabled()) {
+				struct strbuf message = STRBUF_INIT;
+
+				strbuf_addf(&message, "Deleting '%s' because it is not in [", path.buf);
+				for (i = 0; i < ctx->num_commit_graphs_after; i++) {
+					if (i != 0)
+						strbuf_addstr(&message, ", ");
+					strbuf_addf(&message, "'%s'", ctx->commit_graph_filenames_after[i]);
+				}
+				strbuf_addstr(&message, "]");
+				trace2_data_string("commit-graph", the_repository, "graph-deletion", message.buf);
+				strbuf_release(&message);
+				commit_graph_deleted = 1;
+			}
 			unlink(path.buf);
+		}
+	}
+
+	if (commit_graph_deleted) {
+		struct strbuf message = STRBUF_INIT;
+		uint32_t i;
+
+		strbuf_addstr(&message, "The commit graphs before were [");
+		for (i = 0; i < ctx->num_commit_graphs_before; i++) {
+			if (i != 0)
+				strbuf_addstr(&message, ", ");
+			strbuf_addf(&message, "'%s'", ctx->commit_graph_filenames_before[i]);
+		}
+		strbuf_addstr(&message, "]");
+		trace2_data_string("commit-graph", the_repository, "graph-before", message.buf);
+		strbuf_release(&message);
 	}
 
 out:
-- 
2.28.0.rc0.105.gf9edc3c819-goog
Previous: Derrick StoleeNext: Bryan Turner
Message 3 of 6 in “Commit graph chains with no corresponding files?”
  1. Jonathan TanJun 29, 2020
  2. Derrick StoleeJun 30, 2020
  3. [FYI] commit-graph: trace expiry of commit graph linksJonathan Tan, Jul 16, 2020
  4. Bryan TurnerFeb 25, 2021
  5. Derrick StoleeFeb 25, 2021
  6. Bryan TurnerFeb 27, 2021

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.