Skip to content
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

[Bug] Race condition #945

Open
ALX99 opened this issue Dec 5, 2024 · 3 comments · May be fixed by #947
Open

[Bug] Race condition #945

ALX99 opened this issue Dec 5, 2024 · 3 comments · May be fixed by #947

Comments

@ALX99
Copy link
Contributor

ALX99 commented Dec 5, 2024

Environment info:

  • KrakenD version: 2.8.0
  • System info: Should not be needed
  • Hardware specs: Should not be needed
  • Backend technology: Should not be needed

Describe the bug

Race condition detected by Go's race detector

Reproduction:

  1. Compile KrakenD with -race to enable race detection
  2. Run KrakenD with config below and it should crash

Your configuration file:

{
  "version": 3,
  "name": "example",
  "port": 8000,
  "endpoints": [
    {
      "endpoint": "/example",
      "method": "GET",
      "output_encoding": "no-op",
      "backend": [
        {
          "method": "GET",
          "host": [
            "http://example.com"
          ],
          "url_pattern": "/example",
          "extra_config": {
            "backend/http": {
              "return_error_code": true
            }
          }
        }
      ]
    }
  ],
  "extra_config": {
    "telemetry/logging": {
      "custom_format": "%{level} %{time} %{message}",
      "format": "custom",
      "level": "INFO",
      "stdout": true,
      "syslog": false
    }
  }
}

Commands used

./krakend run -c krakend.json

Expected behavior
No crash

Logs

==================
WARNING: DATA RACE
Read at 0x00c000671ba0 by goroutine 24:
  github.com/krakendio/krakend-audit.parseEndpoints()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/[email protected]/parser.go:139 +0x3b0
  github.com/krakendio/krakend-audit.Parse()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/[email protected]/parser.go:80 +0x3a8
  github.com/krakendio/krakend-ce/v2.startReporter.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:446 +0x1d8

Previous write at 0x00c000671ba0 by main goroutine:
  github.com/luraproject/lura/v2/proxy.shadowFactory.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/shadow.go:45 +0x2b8
  github.com/luraproject/lura/v2/proxy.(*shadowFactory).New()
      <autogenerated>:1 +0x4c
  github.com/krakendio/krakend-ce/v2.internalNewProxyFactory.ProxyFactory.func2()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-jsonschema/[email protected]/jsonschema.go:27 +0x5c
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/krakendio/krakend-ce/v2.internalNewProxyFactory.ProxyFactory.func3()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cel/[email protected]/proxy.go:18 +0x98
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/krakendio/krakend-ce/v2.internalNewProxyFactory.ProxyFactory.func4()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-lua/[email protected]/proxy/proxy.go:23 +0x9c
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/luraproject/lura/v2/proxy.Factory.New-fm()
      <autogenerated>:1 +0x50
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/luraproject/lura/v2/proxy.Factory.New-fm()
      <autogenerated>:1 +0x50
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/krakendio/krakend-ce/v2.NewProxyFactory.func1()
      /Users/MASKED/projects/krakend-ce/proxy_factory.go:35 +0x140
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/luraproject/lura/v2/proxy.Factory.New-fm()
      <autogenerated>:1 +0x50
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/luraproject/lura/v2/router/gin.ginRouter.registerKrakendEndpoints()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/router/gin/router.go:138 +0xc8
  github.com/luraproject/lura/v2/router/gin.ginRouter.registerEndpointsAndMiddlewares()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/router/gin/router.go:125 +0x3c4
  github.com/luraproject/lura/v2/router/gin.ginRouter.Run()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/router/gin/router.go:103 +0x170
  github.com/luraproject/lura/v2/router/gin.(*ginRouter).Run()
      <autogenerated>:1 +0xc4
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:235 +0x11c8
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c

Goroutine 24 (running) created at:
  github.com/krakendio/krakend-ce/v2.startReporter()
      /Users/MASKED/projects/krakend-ce/executor.go:440 +0x36c
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:170 +0x288
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c
==================
==================
WARNING: DATA RACE
Read at 0x00c0000e8b68 by goroutine 24:
  github.com/krakendio/krakend-audit.parseEndpoints()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/[email protected]/parser.go:139 +0x704
  github.com/krakendio/krakend-audit.Parse()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/[email protected]/parser.go:80 +0x3a8
  github.com/krakendio/krakend-ce/v2.startReporter.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:446 +0x1d8

Previous write at 0x00c0000e8b68 by main goroutine:
  github.com/luraproject/lura/v2/proxy.shadowFactory.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/shadow.go:42 +0x254
  github.com/luraproject/lura/v2/proxy.(*shadowFactory).New()
      <autogenerated>:1 +0x4c
  github.com/krakendio/krakend-ce/v2.internalNewProxyFactory.ProxyFactory.func2()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-jsonschema/[email protected]/jsonschema.go:27 +0x5c
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/krakendio/krakend-ce/v2.internalNewProxyFactory.ProxyFactory.func3()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cel/[email protected]/proxy.go:18 +0x98
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/krakendio/krakend-ce/v2.internalNewProxyFactory.ProxyFactory.func4()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-lua/[email protected]/proxy/proxy.go:23 +0x9c
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/luraproject/lura/v2/proxy.Factory.New-fm()
      <autogenerated>:1 +0x50
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/luraproject/lura/v2/proxy.Factory.New-fm()
      <autogenerated>:1 +0x50
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/krakendio/krakend-ce/v2.NewProxyFactory.func1()
      /Users/MASKED/projects/krakend-ce/proxy_factory.go:35 +0x140
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/luraproject/lura/v2/proxy.Factory.New-fm()
      <autogenerated>:1 +0x50
  github.com/luraproject/lura/v2/proxy.FactoryFunc.New()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/proxy/factory.go:25 +0x34
  github.com/luraproject/lura/v2/router/gin.ginRouter.registerKrakendEndpoints()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/router/gin/router.go:138 +0xc8
  github.com/luraproject/lura/v2/router/gin.ginRouter.registerEndpointsAndMiddlewares()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/router/gin/router.go:125 +0x3c4
  github.com/luraproject/lura/v2/router/gin.ginRouter.Run()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/router/gin/router.go:103 +0x170
  github.com/luraproject/lura/v2/router/gin.(*ginRouter).Run()
      <autogenerated>:1 +0xc4
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:235 +0x11c8
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c

Goroutine 24 (running) created at:
  github.com/krakendio/krakend-ce/v2.startReporter()
      /Users/MASKED/projects/krakend-ce/executor.go:440 +0x36c
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:170 +0x288
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c
==================
==================
WARNING: DATA RACE
Read at 0x00010598e380 by goroutine 24:
  net/http.(*Client).send()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:180 +0xd4
  net/http.(*Client).do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:725 +0xc6c
  net/http.(*Client).Do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:590 +0x408
  github.com/krakendio/krakend-usage/v2.(*BasicClient).Send()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/http.go:55 +0x340
  github.com/krakendio/krakend-usage/v2.(*Client).NewSession()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/http.go:19 +0xcc
  github.com/krakendio/krakend-usage/v2.New()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/reporter.go:80 +0x63c
  github.com/krakendio/krakend-usage/v2.Report()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/reporter.go:25 +0x5c
  github.com/krakendio/krakend-ce/v2.startReporter.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:448 +0x2f8

Previous write at 0x00010598e380 by main goroutine:
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransportWithLogger.func1()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:78 +0xb0
  sync.(*Once).doSlow()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:76 +0xac
  sync.(*Once).Do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:67 +0x40
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransportWithLogger()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:77 +0x124
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransport()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:64 +0xec
  github.com/luraproject/lura/v2/router/gin.ginRouter.Run()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/router/gin/router.go:101 +0xbc
  github.com/luraproject/lura/v2/router/gin.(*ginRouter).Run()
      <autogenerated>:1 +0xc4
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:235 +0x11c8
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c

Goroutine 24 (running) created at:
  github.com/krakendio/krakend-ce/v2.startReporter()
      /Users/MASKED/projects/krakend-ce/executor.go:440 +0x36c
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:170 +0x288
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c
==================
==================
WARNING: DATA RACE
Read at 0x00c000b1fdd0 by goroutine 24:
  ??()
      -:0 +0x10340da7c
  sync/atomic.LoadUint32()
      <autogenerated>:1 +0x10
  sync.(*Once).Do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:65 +0x30
  net/http.(*Transport).roundTrip()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/transport.go:531 +0x70
  net/http.(*Transport).RoundTrip()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/roundtrip.go:30 +0x30
  net/http.send()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:259 +0x6ec
  net/http.(*Client).send()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:180 +0x100
  net/http.(*Client).do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:725 +0xc6c
  net/http.(*Client).Do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:590 +0x408
  github.com/krakendio/krakend-usage/v2.(*BasicClient).Send()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/http.go:55 +0x340
  github.com/krakendio/krakend-usage/v2.(*Client).NewSession()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/http.go:19 +0xcc
  github.com/krakendio/krakend-usage/v2.New()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/reporter.go:80 +0x63c
  github.com/krakendio/krakend-usage/v2.Report()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/reporter.go:25 +0x5c
  github.com/krakendio/krakend-ce/v2.startReporter.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:448 +0x2f8

Previous write at 0x00c000b1fdd0 by main goroutine:
  github.com/luraproject/lura/v2/transport/http/server.newTransport()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:83 +0x50
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransportWithLogger.func1()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:78 +0xa0
  sync.(*Once).doSlow()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:76 +0xac
  sync.(*Once).Do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:67 +0x40
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransportWithLogger()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:77 +0x124
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransport()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:64 +0xec
  github.com/luraproject/lura/v2/router/gin.ginRouter.Run()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/router/gin/router.go:101 +0xbc
  github.com/luraproject/lura/v2/router/gin.(*ginRouter).Run()
      <autogenerated>:1 +0xc4
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:235 +0x11c8
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c

Goroutine 24 (running) created at:
  github.com/krakendio/krakend-ce/v2.startReporter()
      /Users/MASKED/projects/krakend-ce/executor.go:440 +0x36c
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:170 +0x288
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c
==================
==================
WARNING: DATA RACE
Read at 0x00c000b1fda0 by goroutine 24:
  net/http.(*Transport).onceSetNextProtoDefaults()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/transport.go:370 +0x44
  net/http.(*Transport).onceSetNextProtoDefaults-fm()
      <autogenerated>:1 +0x34
  sync.(*Once).doSlow()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:76 +0xac
  sync.(*Once).Do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:67 +0x40
  net/http.(*Transport).roundTrip()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/transport.go:531 +0x70
  net/http.(*Transport).RoundTrip()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/roundtrip.go:30 +0x30
  net/http.send()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:259 +0x6ec
  net/http.(*Client).send()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:180 +0x100
  net/http.(*Client).do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:725 +0xc6c
  net/http.(*Client).Do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:590 +0x408
  github.com/krakendio/krakend-usage/v2.(*BasicClient).Send()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/http.go:55 +0x340
  github.com/krakendio/krakend-usage/v2.(*Client).NewSession()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/http.go:19 +0xcc
  github.com/krakendio/krakend-usage/v2.New()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/reporter.go:80 +0x63c
  github.com/krakendio/krakend-usage/v2.Report()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/reporter.go:25 +0x5c
  github.com/krakendio/krakend-ce/v2.startReporter.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:448 +0x2f8

Previous write at 0x00c000b1fda0 by main goroutine:
  github.com/luraproject/lura/v2/transport/http/server.newTransport()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:83 +0x50
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransportWithLogger.func1()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:78 +0xa0
  sync.(*Once).doSlow()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:76 +0xac
  sync.(*Once).Do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:67 +0x40
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransportWithLogger()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:77 +0x124
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransport()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:64 +0xec
  github.com/luraproject/lura/v2/router/gin.ginRouter.Run()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/router/gin/router.go:101 +0xbc
  github.com/luraproject/lura/v2/router/gin.(*ginRouter).Run()
      <autogenerated>:1 +0xc4
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:235 +0x11c8
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c

Goroutine 24 (running) created at:
  github.com/krakendio/krakend-ce/v2.startReporter()
      /Users/MASKED/projects/krakend-ce/executor.go:440 +0x36c
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:170 +0x288
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c
==================
==================
WARNING: DATA RACE
Write at 0x00c000b1fdf0 by goroutine 24:
  net/http.(*Transport).onceSetNextProtoDefaults()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/transport.go:370 +0x58
  net/http.(*Transport).onceSetNextProtoDefaults-fm()
      <autogenerated>:1 +0x34
  sync.(*Once).doSlow()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:76 +0xac
  sync.(*Once).Do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:67 +0x40
  net/http.(*Transport).roundTrip()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/transport.go:531 +0x70
  net/http.(*Transport).RoundTrip()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/roundtrip.go:30 +0x30
  net/http.send()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:259 +0x6ec
  net/http.(*Client).send()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:180 +0x100
  net/http.(*Client).do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:725 +0xc6c
  net/http.(*Client).Do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/net/http/client.go:590 +0x408
  github.com/krakendio/krakend-usage/v2.(*BasicClient).Send()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/http.go:55 +0x340
  github.com/krakendio/krakend-usage/v2.(*Client).NewSession()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/http.go:19 +0xcc
  github.com/krakendio/krakend-usage/v2.New()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/reporter.go:80 +0x63c
  github.com/krakendio/krakend-usage/v2.Report()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-usage/[email protected]/reporter.go:25 +0x5c
  github.com/krakendio/krakend-ce/v2.startReporter.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:448 +0x2f8

Previous write at 0x00c000b1fdf0 by main goroutine:
  github.com/luraproject/lura/v2/transport/http/server.newTransport()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:83 +0x50
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransportWithLogger.func1()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:78 +0xa0
  sync.(*Once).doSlow()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:76 +0xac
  sync.(*Once).Do()
      /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:67 +0x40
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransportWithLogger()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:77 +0x124
  github.com/luraproject/lura/v2/transport/http/server.InitHTTPDefaultTransport()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/transport/http/server/server.go:64 +0xec
  github.com/luraproject/lura/v2/router/gin.ginRouter.Run()
      /Users/MASKED/go/pkg/mod/github.com/luraproject/lura/[email protected]/router/gin/router.go:101 +0xbc
  github.com/luraproject/lura/v2/router/gin.(*ginRouter).Run()
      <autogenerated>:1 +0xc4
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:235 +0x11c8
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c

Goroutine 24 (running) created at:
  github.com/krakendio/krakend-ce/v2.startReporter()
      /Users/MASKED/projects/krakend-ce/executor.go:440 +0x36c
  github.com/krakendio/krakend-ce/v2.NewExecutor.(*ExecutorBuilder).NewCmdExecutor.func1()
      /Users/MASKED/projects/krakend-ce/executor.go:170 +0x288
  github.com/krakendio/krakend-cobra/v2.runFunc()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/run.go:24 +0x28c
  github.com/spf13/cobra.(*Command).execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xc18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x4bc
  github.com/spf13/cobra.(*Command).Execute()
      /Users/MASKED/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0xe0
  github.com/krakendio/krakend-cobra/v2.Root.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:129 +0x18
  github.com/krakendio/krakend-cobra/v2.ExecuteRoot()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:26 +0xec
  github.com/krakendio/krakend-cobra/v2.Execute()
      /Users/MASKED/go/pkg/mod/github.com/krakendio/krakend-cobra/[email protected]/cmd.go:21 +0xa54
  main.main()
      /Users/MASKED/projects/krakend-ce/cmd/krakend-ce/main.go:72 +0x31c
==================
@thedae
Copy link
Member

thedae commented Dec 9, 2024

Hi @ALX99 thanks for the bug report. We've been checking this out and we are able to reproduce in 2.8.0 and older versions. We already have a fix and will be released soon.

I'd also like to point out that KrakenD is designed to work concurrently in many places to be as performant as possible, and this can lead to race warnings at compilation time. Having said that, our test suite covers most of the use cases and it's also executed with the race flag enabled, so it's unlikely for problematic race conditions to happen in a live environment.

@ALX99
Copy link
Contributor Author

ALX99 commented Dec 10, 2024

Hello @thedae,
Thank you for having a look.
We haven't experienced any issues either. I just happened to stumble across it when wanting to check for race conditions in our own plugins.

Could you elaborate on:

this can lead to race warnings at compilation time

Does it mean that KrakenD won't support the use case of compiling it with -race?

@thedae
Copy link
Member

thedae commented Dec 10, 2024

Does it mean that KrakenD won't support the use case of compiling it with -race?

Yes, it does, and the binary compiled with -race triggers some warnings a few seconds after starting up, but works perfectly.

In any case, we are preparing a quick fix to get rid of those warnings, I'll keep you posted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants