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>2022-04-26 14:15:57 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-04-27 09:57:38 +0300
commit8121c06576223f4dbc32ac26ed521239e89345f2 (patch)
tree7fc57b9ed6402158f0b81fd06c1d57317c9b8561
parent44cb119f10c57824411a6aab44ae02a07964e0d5 (diff)
catfile: Fix losing all context information on decorrelationpks-catfile-fix-flaky-process-termination-test
When creating a new cached catfile process we need to decorrelate it from the parent context. For one this means that we need to remove the correlation ID and any tracing spans from the context. And second it means we need to suppress cancellation of the parent so that our cached process doesn't get killed when the RPC context is cancelled. The way we do this right now is to use `context.Background()`: this just creates a completely new background. Funny enough, we still try to strip information from this new context, which doesn't make any sense given that it's empty already. But this hints at an actual bug: the intent is not to get a completely new context, but by using `context.Background()` we also lose information such as feature flags here. Fix this bug by not creating a completely new context. Instead, we just suppress context cancellation via `helper.SuppressCancellation()` and then continue to decorrelate it like we always used to do. Only that now it actually does something. Changelog: fixed
-rw-r--r--internal/git/catfile/cache.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/git/catfile/cache.go b/internal/git/catfile/cache.go
index 7069bbd85..712f9bb4c 100644
--- a/internal/git/catfile/cache.go
+++ b/internal/git/catfile/cache.go
@@ -14,6 +14,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
+ "gitlab.com/gitlab-org/labkit/correlation"
)
const (
@@ -231,7 +232,14 @@ func (c *ProcessCache) getOrCreateProcess(
// We have not found any cached process, so we need to create a new one. In this
// case, we need to detach the process from the current context such that it does
// not get killed when the parent context is cancelled.
- ctx = context.Background()
+ //
+ // Note that we explicitly retain feature flags here, which means that cached
+ // processes may retain flags for some time which have been changed meanwhile. While
+ // not ideal, it feels better compared to just ignoring feature flags altogether.
+ // The latter would mean that we cannot use flags in the catfile code, but more
+ // importantly we also wouldn't be able to use feature-flagged Git version upgrades
+ // for catfile processes.
+ ctx = helper.SuppressCancellation(ctx)
// We have to decorrelate the process from the current context given that it
// may potentially be reused across different RPC calls.
ctx = correlation.ContextWithCorrelation(ctx, "")