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:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-12-12 08:52:59 +0300
committerGitLab <noreply@gitlab.com>2023-12-12 08:52:59 +0300
commit3fa4f66b3db439e87a080535d3899f1752286230 (patch)
tree0e50e50af2a0e7897b0d810aac104c482d1f755a
parente4c3cf70dac0562f2ddfb5f851cfe3f7f40c17f9 (diff)
parent1bfbf59b7873cc7bb571dfa8667a52ec11337966 (diff)
Merge branch '5729-flaky-test-testcatfileobject-spawning_two_pipes_fails' into 'master'
catfile: Fix race condition in `CatfileObject` Closes #5729 See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6578 Merged-by: Patrick Steinhardt <psteinhardt@gitlab.com> Co-authored-by: Karthik Nayak <knayak@gitlab.com>
-rw-r--r--internal/git/gitpipe/catfile_object.go4
-rw-r--r--internal/git/gitpipe/catfile_object_test.go1
2 files changed, 3 insertions, 2 deletions
diff --git a/internal/git/gitpipe/catfile_object.go b/internal/git/gitpipe/catfile_object.go
index b809923d9..77c7fecd4 100644
--- a/internal/git/gitpipe/catfile_object.go
+++ b/internal/git/gitpipe/catfile_object.go
@@ -48,10 +48,10 @@ func CatfileObject(
requestChan := make(chan catfileObjectRequest, 32)
go func() {
defer func() {
- close(requestChan)
if atomic.AddInt32(&queueRefcount, -1) == 0 {
queueCleanup()
}
+ close(requestChan)
}()
sendRequest := func(request catfileObjectRequest) bool {
@@ -115,10 +115,10 @@ func CatfileObject(
resultChan := make(chan CatfileObjectResult)
go func() {
defer func() {
- close(resultChan)
if atomic.AddInt32(&queueRefcount, -1) == 0 {
queueCleanup()
}
+ close(resultChan)
}()
sendResult := func(result CatfileObjectResult) bool {
diff --git a/internal/git/gitpipe/catfile_object_test.go b/internal/git/gitpipe/catfile_object_test.go
index b53d86aea..59872be13 100644
--- a/internal/git/gitpipe/catfile_object_test.go
+++ b/internal/git/gitpipe/catfile_object_test.go
@@ -243,6 +243,7 @@ func TestCatfileObject(t *testing.T) {
_, err = io.Copy(io.Discard, it.Result())
require.NoError(t, err)
require.False(t, it.Next())
+ require.NoError(t, it.Err())
// Which means that the queue should now be unused, so we can again use it.
_, err = CatfileObject(ctx, objectReader, NewRevisionIterator(ctx, input))