Skip to content

Commit

Permalink
gitserver: SRC_ENABLE_GC_AUTO to enable & disable gc on fetch (source…
Browse files Browse the repository at this point in the history
  • Loading branch information
abeatrix committed Feb 21, 2023
1 parent 4a20c86 commit 382b481
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ All notable changes to Sourcegraph are documented in this file.
### Fixed

- Fixed issues with propagating tracing configuration throughout the application. [#47428](https://github.com/sourcegraph/sourcegraph/pull/47428)
- Enable `auto gc` on fetch when `SRC_ENABLE_GC_AUTO` is set to `true`. [#47852](https://github.com/sourcegraph/sourcegraph/pull/47852)

### Removed

Expand Down
4 changes: 2 additions & 2 deletions cmd/gitserver/server/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -1401,10 +1401,10 @@ func tooManyPackfiles(dir GitDir, limit int) (bool, error) {
// git-gc operations are running at the same time.
func gitSetAutoGC(dir GitDir) error {
switch gitGCMode {
case gitGCModeGitAutoGC:
case gitGCModeGitAutoGC, gitGCModeJanitorAutoGC:
return gitConfigUnset(dir, "gc.auto")

case gitGCModeJanitorAutoGC, gitGCModeMaintenance:
case gitGCModeMaintenance:
return gitConfigSet(dir, "gc.auto", "0")

default:
Expand Down
2 changes: 1 addition & 1 deletion cmd/gitserver/server/refspecoverrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ func useRefspecOverrides() bool {
// HACK(keegancsmith) workaround to experiment with cloning less in a large
// monorepo. https://github.com/sourcegraph/customer/issues/19
func refspecOverridesFetchCmd(ctx context.Context, remoteURL *vcs.URL) *exec.Cmd {
return exec.CommandContext(ctx, "git", append([]string{"fetch", "--no-auto-gc", "--progress", "--prune", remoteURL.String()}, refspecOverrides...)...)
return exec.CommandContext(ctx, "git", append([]string{"fetch", "--progress", "--prune", remoteURL.String()}, refspecOverrides...)...)
}
3 changes: 2 additions & 1 deletion cmd/gitserver/server/serverutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"time"

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"

"github.com/sourcegraph/sourcegraph/internal/conf"
"github.com/sourcegraph/sourcegraph/schema"
"github.com/stretchr/testify/assert"
)

func TestGetTlsExternal(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions cmd/gitserver/server/vcs_syncer_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/exec"

"github.com/sourcegraph/log"

"github.com/sourcegraph/sourcegraph/internal/vcs"
"github.com/sourcegraph/sourcegraph/internal/wrexec"
"github.com/sourcegraph/sourcegraph/lib/errors"
Expand Down Expand Up @@ -103,9 +104,6 @@ func (s *GitRepoSyncer) fetchCommand(ctx context.Context, remoteURL *vcs.URL) (c
cmd = refspecOverridesFetchCmd(ctx, remoteURL)
} else {
cmd = exec.CommandContext(ctx, "git", "fetch",
// We already have janitor jobs that run git gc. We disable git gc here to avoid
// a possible corruption of repositories by competing gc processes.
"--no-auto-gc",
"--progress", "--prune", remoteURL.String(),
// Normal git refs
"+refs/heads/*:refs/heads/*", "+refs/tags/*:refs/tags/*",
Expand Down

0 comments on commit 382b481

Please sign in to comment.