Conversation
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff a071a07...d41d313.
|
| return exec.CommandContext(ctx, "git", append([]string{"fetch", "--no-auto-gc", "--progress", "--prune", remoteURL.String()}, refspecOverrides...)...) | ||
| // Perform automatic repository maintenance at the end of fetch | ||
| gc := "--auto-gc" | ||
| if e := os.Getenv("SRC_ENABLE_GC_AUTO"); e == "false" { |
There was a problem hiding this comment.
nit: maybe strconv.ParseBool would be better here? Especially because customers will set this, there might be a lot of variation in how they set it.
There was a problem hiding this comment.
Why do we have to check the env var here again? Can't we check whether gitGCMode == gitGCModeGitAutoGC?
We already parse the env var here and already have some logic to set the GC mode here: https://github.com/sourcegraph/sourcegraph/blob/37458d2484d78de53765dfaea929be7c22e611cf/cmd/gitserver/server/cleanup.go#L56-L87
I think we should reuse that instead of adding another place where things can change.
| } else { | ||
| // Perform automatic repository maintenance at the end of fetch | ||
| gc := "--auto-gc" | ||
| if e := os.Getenv("SRC_ENABLE_GC_AUTO"); e == "false" { |
There was a problem hiding this comment.
Same as above: let's reuse gitGCMode or at least the parsing of the env var or move this check over to the the others and use .envGet.
indradhanush
left a comment
There was a problem hiding this comment.
Not a blocker, but could you please add a section to the end of this doc to document this new behaviour?
Can be a follow up PR as well. Leaving the comment so that it's tracked.
mrnugget
left a comment
There was a problem hiding this comment.
Thanks for hopping on this! Requesting changes because I think we should reuse the GC mode variable OR move the parsing of the env var closer to the others.
| return exec.CommandContext(ctx, "git", append([]string{"fetch", "--no-auto-gc", "--progress", "--prune", remoteURL.String()}, refspecOverrides...)...) | ||
| // Perform automatic repository maintenance at the end of fetch | ||
| gc := "--auto-gc" | ||
| if e := os.Getenv("SRC_ENABLE_GC_AUTO"); e == "false" { |
There was a problem hiding this comment.
Why do we have to check the env var here again? Can't we check whether gitGCMode == gitGCModeGitAutoGC?
We already parse the env var here and already have some logic to set the GC mode here: https://github.com/sourcegraph/sourcegraph/blob/37458d2484d78de53765dfaea929be7c22e611cf/cmd/gitserver/server/cleanup.go#L56-L87
I think we should reuse that instead of adding another place where things can change.
| } else { | ||
| // Perform automatic repository maintenance at the end of fetch | ||
| gc := "--auto-gc" | ||
| if e := os.Getenv("SRC_ENABLE_GC_AUTO"); e == "false" { |
There was a problem hiding this comment.
Same as above: let's reuse gitGCMode or at least the parsing of the env var or move this check over to the the others and use .envGet.
| cmd = refspecOverridesFetchCmd(ctx, remoteURL) | ||
| } else { | ||
| // Perform automatic repository maintenance at the end of fetch | ||
| gc := "--auto-gc" |
There was a problem hiding this comment.
Do we even need to set this explicitly? I kinda assumed that, depending on the GC mode we use, we set gc.auto = 1 or 0 in the git config. See: https://github.com/sourcegraph/sourcegraph/blob/37458d2484d78de53765dfaea929be7c22e611cf/cmd/gitserver/server/cleanup.go#L1402-L1420
|
Thank you all for the reviews! I wasn't aware of gitGCMode but what @mrnugget suggested makes sense to me. I do have a follow-up question to make sure I understand the current implementations correctly. It looks like we disable |
I'll let @stefanhengl answer here (since he added it in https://github.com/sourcegraph/sourcegraph/commit/f461a4ae253faa2752d2bc64d049c90569de7a1f) but I think the thinking is this: if we use But: aren't we now discovering that even with janitor-git-gc-runs we still run into these problems and we should probably also use |
@mrnugget Yea that's what I believe is the issue as well and have updated to enable edit: @stefanhengl should we also remove the hard-coded |
From the docs
This is an aggressive setting for packing but AFAIK we never had trouble with it. Changing it might blow up dir sizes on gitserver. I never changed it and unless we have specific reason to remove it I wouldn't touch it. |
Once it became obvious that sg maintenance caused repo corruption for customers with large repos I tried to lock down any unintentional garbage collection run by git porcelain commands IE I wanted to make sure our janitor job is the only one running gc. This whole approach failed and I recommend to take the original implementation (before I added sg maintenance) as baseline. The original implementation didn't set any repo config options like we do in |
Close https://github.com/sourcegraph/customer/issues/1955
Context: A customer is encountering an issue with one of their fast-moving repo that caused the repo unable to sync & index, making it unsearchable (context). We suspected the addition of
--no-auto-gcin https://github.com/sourcegraph/sourcegraph/pull/36274 is the cause as the issue started after performing MVU, and the error went away when runninggit gcmanually inside gitserver.Included in this PR:
gconfetchTest plan
Ran locally to confirm setting
SRC_ENABLE_GC_AUTOwould toggle the command flag: