-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extkingpin: fix Content/Rewrite race #6870
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Got this during `TestLimiter_StartConfigReloader`: ``` Read at 0x00c0005123f0 by goroutine 8711: github.com/thanos-io/thanos/pkg/extkingpin.(*staticPathContent).Content() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:90 +0x28 github.com/thanos-io/thanos/pkg/receive.ParseLimitConfigContent() /home/giedrius/dev/thanos/pkg/receive/limiter.go:203 +0x3e github.com/thanos-io/thanos/pkg/receive.(*Limiter).loadConfig() /home/giedrius/dev/thanos/pkg/receive/limiter.go:143 +0x65 github.com/thanos-io/thanos/pkg/receive.(*Limiter).StartConfigReloader.func1() /home/giedrius/dev/thanos/pkg/receive/limiter.go:119 +0x207 github.com/thanos-io/thanos/pkg/extkingpin.(*pollingEngine).start.func1() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:64 +0x6b8 github.com/thanos-io/thanos/pkg/extkingpin.(*pollingEngine).start.func2() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:74 +0x56 Previous write at 0x00c0005123f0 by goroutine 8710: github.com/thanos-io/thanos/pkg/extkingpin.(*staticPathContent).Rewrite() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:111 +0x529 github.com/thanos-io/thanos/pkg/receive.TestLimiter_StartConfigReloader() /home/giedrius/dev/thanos/pkg/receive/limiter_test.go:44 +0x5aa testing.tRunner() /usr/lib/go-1.21/src/testing/testing.go:1595 +0x238 testing.(*T).Run.func1() /usr/lib/go-1.21/src/testing/testing.go:1648 +0x44 ``` Fix it by protecting `t.content` with a mutex and by copying the content's slice so that the caller wouldn't have access to the original slice. Signed-off-by: Giedrius Statkevičius <[email protected]>
fpetkovski
approved these changes
Nov 3, 2023
rabenhorst
pushed a commit
to rabenhorst/thanos
that referenced
this pull request
Nov 15, 2023
Got this during `TestLimiter_StartConfigReloader`: ``` Read at 0x00c0005123f0 by goroutine 8711: github.com/thanos-io/thanos/pkg/extkingpin.(*staticPathContent).Content() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:90 +0x28 github.com/thanos-io/thanos/pkg/receive.ParseLimitConfigContent() /home/giedrius/dev/thanos/pkg/receive/limiter.go:203 +0x3e github.com/thanos-io/thanos/pkg/receive.(*Limiter).loadConfig() /home/giedrius/dev/thanos/pkg/receive/limiter.go:143 +0x65 github.com/thanos-io/thanos/pkg/receive.(*Limiter).StartConfigReloader.func1() /home/giedrius/dev/thanos/pkg/receive/limiter.go:119 +0x207 github.com/thanos-io/thanos/pkg/extkingpin.(*pollingEngine).start.func1() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:64 +0x6b8 github.com/thanos-io/thanos/pkg/extkingpin.(*pollingEngine).start.func2() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:74 +0x56 Previous write at 0x00c0005123f0 by goroutine 8710: github.com/thanos-io/thanos/pkg/extkingpin.(*staticPathContent).Rewrite() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:111 +0x529 github.com/thanos-io/thanos/pkg/receive.TestLimiter_StartConfigReloader() /home/giedrius/dev/thanos/pkg/receive/limiter_test.go:44 +0x5aa testing.tRunner() /usr/lib/go-1.21/src/testing/testing.go:1595 +0x238 testing.(*T).Run.func1() /usr/lib/go-1.21/src/testing/testing.go:1648 +0x44 ``` Fix it by protecting `t.content` with a mutex and by copying the content's slice so that the caller wouldn't have access to the original slice. Signed-off-by: Giedrius Statkevičius <[email protected]> Signed-off-by: Sebastian Rabenhorst <[email protected]>
douglascamata
pushed a commit
to douglascamata/thanos
that referenced
this pull request
Dec 13, 2023
Got this during `TestLimiter_StartConfigReloader`: ``` Read at 0x00c0005123f0 by goroutine 8711: github.com/thanos-io/thanos/pkg/extkingpin.(*staticPathContent).Content() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:90 +0x28 github.com/thanos-io/thanos/pkg/receive.ParseLimitConfigContent() /home/giedrius/dev/thanos/pkg/receive/limiter.go:203 +0x3e github.com/thanos-io/thanos/pkg/receive.(*Limiter).loadConfig() /home/giedrius/dev/thanos/pkg/receive/limiter.go:143 +0x65 github.com/thanos-io/thanos/pkg/receive.(*Limiter).StartConfigReloader.func1() /home/giedrius/dev/thanos/pkg/receive/limiter.go:119 +0x207 github.com/thanos-io/thanos/pkg/extkingpin.(*pollingEngine).start.func1() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:64 +0x6b8 github.com/thanos-io/thanos/pkg/extkingpin.(*pollingEngine).start.func2() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:74 +0x56 Previous write at 0x00c0005123f0 by goroutine 8710: github.com/thanos-io/thanos/pkg/extkingpin.(*staticPathContent).Rewrite() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:111 +0x529 github.com/thanos-io/thanos/pkg/receive.TestLimiter_StartConfigReloader() /home/giedrius/dev/thanos/pkg/receive/limiter_test.go:44 +0x5aa testing.tRunner() /usr/lib/go-1.21/src/testing/testing.go:1595 +0x238 testing.(*T).Run.func1() /usr/lib/go-1.21/src/testing/testing.go:1648 +0x44 ``` Fix it by protecting `t.content` with a mutex and by copying the content's slice so that the caller wouldn't have access to the original slice. Signed-off-by: Giedrius Statkevičius <[email protected]>
douglascamata
pushed a commit
to douglascamata/thanos
that referenced
this pull request
Dec 13, 2023
Got this during `TestLimiter_StartConfigReloader`: ``` Read at 0x00c0005123f0 by goroutine 8711: github.com/thanos-io/thanos/pkg/extkingpin.(*staticPathContent).Content() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:90 +0x28 github.com/thanos-io/thanos/pkg/receive.ParseLimitConfigContent() /home/giedrius/dev/thanos/pkg/receive/limiter.go:203 +0x3e github.com/thanos-io/thanos/pkg/receive.(*Limiter).loadConfig() /home/giedrius/dev/thanos/pkg/receive/limiter.go:143 +0x65 github.com/thanos-io/thanos/pkg/receive.(*Limiter).StartConfigReloader.func1() /home/giedrius/dev/thanos/pkg/receive/limiter.go:119 +0x207 github.com/thanos-io/thanos/pkg/extkingpin.(*pollingEngine).start.func1() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:64 +0x6b8 github.com/thanos-io/thanos/pkg/extkingpin.(*pollingEngine).start.func2() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:74 +0x56 Previous write at 0x00c0005123f0 by goroutine 8710: github.com/thanos-io/thanos/pkg/extkingpin.(*staticPathContent).Rewrite() /home/giedrius/dev/thanos/pkg/extkingpin/path_content_reloader.go:111 +0x529 github.com/thanos-io/thanos/pkg/receive.TestLimiter_StartConfigReloader() /home/giedrius/dev/thanos/pkg/receive/limiter_test.go:44 +0x5aa testing.tRunner() /usr/lib/go-1.21/src/testing/testing.go:1595 +0x238 testing.(*T).Run.func1() /usr/lib/go-1.21/src/testing/testing.go:1648 +0x44 ``` Fix it by protecting `t.content` with a mutex and by copying the content's slice so that the caller wouldn't have access to the original slice. Signed-off-by: Giedrius Statkevičius <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Got this during
TestLimiter_StartConfigReloader
:Fix it by protecting
t.content
with a mutex and by copying the content's slice so that the caller wouldn't have access to the original slice.Changes
Verification