All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Tan <jonathantanmy@google.com>
To: git@vger.kernel.org
Cc: Jonathan Tan <jonathantanmy@google.com>, stolee@gmail.com
Subject: [FYI] commit-graph: trace expiry of commit graph links
Date: Thu, 16 Jul 2020 15:57:25 -0700	[thread overview]
Message-ID: <20200716225725.4143039-1-jonathantanmy@google.com> (raw)
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


  reply	other threads:[~2020-07-16 23:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29 22:07 Commit graph chains with no corresponding files? Jonathan Tan
2020-06-30  1:51 ` Derrick Stolee
2020-07-16 22:57   ` Jonathan Tan [this message]
2021-02-25  4:54   ` Bryan Turner
2021-02-25 14:20     ` Derrick Stolee
2021-02-27  2:49       ` Bryan Turner

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200716225725.4143039-1-jonathantanmy@google.com \
    --to=jonathantanmy@google.com \
    --cc=git@vger.kernel.org \
    --cc=stolee@gmail.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.