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>2021-09-01 15:31:53 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-09-01 15:31:53 +0300
commitb021b9075ba04dedf7e925bab162366e9c6e6446 (patch)
treecd67dd8be2a7fe75f38516d0a765207a04e3eff8
parent8a836229e471c44f7a95122691f76122095aaeda (diff)
coordinator: Fix test races caused by concurrent repository creation
Because most of our tests won't ever create repository records in the database when they set up a repository, we have a workaround in the coordinator which creates database records for repositories whenever we see a repository-scoped message. This approach is currently racy though: in case we have multiple concurrent repository-scoped RPC calls, we'll try to create the same repository multiple times. The result is that one of both RPCs will fail with an error. Fix this issue by ignoring `RepositoryExistsError`s when force-creating the database entries.
-rw-r--r--internal/praefect/coordinator.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/internal/praefect/coordinator.go b/internal/praefect/coordinator.go
index 218d5fbb3..66a828b59 100644
--- a/internal/praefect/coordinator.go
+++ b/internal/praefect/coordinator.go
@@ -340,7 +340,9 @@ func (c *Coordinator) directRepositoryScopedMessage(ctx context.Context, call gr
}
} else {
if err := c.rs.CreateRepository(ctx, id, call.targetRepo.StorageName, call.targetRepo.RelativePath, call.targetRepo.StorageName, nil, nil, true, true); err != nil {
- return nil, err
+ if !errors.As(err, &datastore.RepositoryExistsError{}) {
+ return nil, err
+ }
}
}
}