Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Okstad <pokstad@gitlab.com>2019-09-03 19:21:54 +0300
committerPaul Okstad <pokstad@gitlab.com>2019-09-03 19:21:54 +0300
commit85dab6bcb4c37c44fe67fc2d85e571e544b5396c (patch)
tree36ba2b1e804ea45be75b7247d55680e826ef6a89
parent33f2486333d3c4df9c4a8904d4c3c270bc629210 (diff)
parente312b20336ce76b9dfa03445ff8677f7d1ca6731 (diff)
Merge branch 'jv-catfile-metrics-bug' into 'master'
Fix catfile metrics counting bug Closes #1902 See merge request gitlab-org/gitaly!1462
-rw-r--r--changelogs/unreleased/jv-catfile-metrics-bug.yml5
-rw-r--r--internal/git/catfile/batch.go9
2 files changed, 11 insertions, 3 deletions
diff --git a/changelogs/unreleased/jv-catfile-metrics-bug.yml b/changelogs/unreleased/jv-catfile-metrics-bug.yml
new file mode 100644
index 000000000..c69764f32
--- /dev/null
+++ b/changelogs/unreleased/jv-catfile-metrics-bug.yml
@@ -0,0 +1,5 @@
+---
+title: Fix catfile metrics counting bug
+merge_request: 1462
+author:
+type: fixed
diff --git a/internal/git/catfile/batch.go b/internal/git/catfile/batch.go
index 737a651ac..d37c9c718 100644
--- a/internal/git/catfile/batch.go
+++ b/internal/git/catfile/batch.go
@@ -31,22 +31,25 @@ type batchProcess struct {
}
func newBatchProcess(ctx context.Context, repoPath string, env []string) (*batchProcess, error) {
+ totalCatfileProcesses.Inc()
+
b := &batchProcess{}
var stdinReader io.Reader
stdinReader, b.w = io.Pipe()
batchCmdArgs := []string{"--git-dir", repoPath, "cat-file", "--batch"}
- currentCatfileProcesses.Inc()
- totalCatfileProcesses.Inc()
batchCmd, err := git.BareCommand(ctx, stdinReader, nil, nil, env, batchCmdArgs...)
if err != nil {
return nil, err
}
+
b.r = bufio.NewReader(batchCmd)
+
+ currentCatfileProcesses.Inc()
go func() {
<-ctx.Done()
- // This is crucial to prevent leaking file descriptors.
+ // This Close() is crucial to prevent leaking file descriptors.
b.w.Close()
currentCatfileProcesses.Dec()
}()