From c5d5abaa3b01638644af622970899715e8fe7527 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Thu, 27 Jun 2024 11:02:36 -0400 Subject: [PATCH] gvfs-helper: don't fallback with new config By default, GVFS Protocol-enabled Scalar clones will fall back to the origin server if there is a network issue with the cache servers. However (and especially for the prefetch endpoint) this may be a very expensive operation for the origin server, leading to the user being throttled. This shows up later in cases such as 'git push' or other web operations. To avoid this, create a new config option, 'gvfs.fallback', which defaults to true. When set to 'false', pass '--no-fallback' from the gvfs-helper client to the child gvfs-helper server process. This will allow users who have hit this problem to avoid it in the future. In case this becomes a more widespread problem, engineering systems can enable the config option more broadly. Enabling the config will of course lead to immediate failures for users, but at least that will help diagnose the problem when it occurs instead of later when the throttling shows up and the server load has already passed, damage done. Signed-off-by: Derrick Stolee --- Documentation/config/gvfs.txt | 5 +++++ gvfs-helper-client.c | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Documentation/config/gvfs.txt b/Documentation/config/gvfs.txt index 6ab221ded36c91..7224939ac0b270 100644 --- a/Documentation/config/gvfs.txt +++ b/Documentation/config/gvfs.txt @@ -3,3 +3,8 @@ gvfs.cache-server:: gvfs.sharedcache:: TODO + +gvfs.fallback:: + If set to `false`, then never fallback to the origin server when the cache + server fails to connect. This will alert users to failures with the cache + server, but avoid causing throttling on the origin server. diff --git a/gvfs-helper-client.c b/gvfs-helper-client.c index 6f38fe1c4353d0..45d4d86783c73b 100644 --- a/gvfs-helper-client.c +++ b/gvfs-helper-client.c @@ -14,6 +14,7 @@ #include "quote.h" #include "packfile.h" #include "hex.h" +#include "config.h" static struct oidset gh_client__oidset_queued = OIDSET_INIT; static unsigned long gh_client__oidset_count; @@ -339,6 +340,7 @@ static struct gh_server__process *gh_client__find_long_running_process( struct gh_server__process *entry; struct strvec argv = STRVEC_INIT; struct strbuf quoted = STRBUF_INIT; + int fallback; gh_client__choose_odb(); @@ -346,10 +348,17 @@ static struct gh_server__process *gh_client__find_long_running_process( * TODO decide what defaults we want. */ strvec_push(&argv, "gvfs-helper"); - strvec_push(&argv, "--fallback"); strvec_push(&argv, "--cache-server=trust"); strvec_pushf(&argv, "--shared-cache=%s", gh_client__chosen_odb->path); + + /* If gvfs.fallback=false, then don't add --fallback. */ + if (!git_config_get_bool("gvfs.fallback", &fallback) && + !fallback) + strvec_push(&argv, "--no-fallback"); + else + strvec_push(&argv, "--fallback"); + strvec_push(&argv, "server"); sq_quote_argv_pretty("ed, argv.v);