caddy: fatal error: concurrent map read and map write after upgrading 2.7.6 to 2.8.4 and/or adding github.com/caddyserver/cache-handler

1. What version of Caddy are you running (caddy -version)?

now 2.8.4 with

xcaddy build --output bin/LRTcaddy --with github.com/christophcemper/caddy-netlify-redirects@v0.2.4 --with github.com/caddyserver/transform-encoder --with github.com/pteich/caddy-tlsconsul --with github.com/caddyserver/cache-handler

after 10 month stable 2.7.6. with

xcaddy build --output bin/LRTcaddy --with github.com/christophcemper/caddy-netlify-redirects@v0.2.4 --with github.com/caddyserver/transform-encoder --with github.com/pteich/caddy-tlsconsul

that did not experience this very rare, unseen before crash

2. What are you trying to do?

Multiple production hosts, reverse proxies, etc.

We added the module github.com/caddyserver/cache-handler for a project and (unfortunately) also upgraded from 2.7.6 to 2.8.4. in one step.

Since then we had 2 occassions of a crash of Caddy on Oct 28 and Nov 10 that caused a total outage and could only be remedied with a manual restart.

3. What is your entire Caddyfile?

Sorry we cannot share it in public, happy to send directly to mholt or other key people.

4. How did you run Caddy (give the full command and describe the execution environment)?

/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile


via a systemd service

systemctl status caddy
● caddy.service - Caddy
     Loaded: loaded (/lib/systemd/system/caddy.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2024-11-10 11:45:13 UTC; 7h ago
       Docs: https://caddyserver.com/docs/
    Process: 1929477 ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force (code=exited, status=0/SUCCESS)
   Main PID: 1879405 (caddy)
      Tasks: 39 (limit: 154411)
     Memory: 2.2G
     CGroup: /system.slice/caddy.service
             └─1879405 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile

5. What did you expect to see?

Stable caddy like all the time before.

6. What did you see instead (give full error messages and/or log)?

Oct 28 (intro for 1st goroutine - longer log attached)

Oct 28 15:05:08 web01 caddy[2621539]: fatal **error:** concurrent map read and map write

Oct 28 15:05:08 web01 caddy[2621539]: goroutine 3873976361 [running]:

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.GetVar({0x1f9bd08?, 0xc015b73290?}, {0x1a68ef6, 0xe})

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/vars.go:323 +0x57

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:257 +0x1c6

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f3291d534b0?, 0xc049806a80?}, 0xe?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f3291d534b0, 0xc049806a80}, 0xc045f00480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f86720?, {0x7f3291d534b0?, 0xc049806a80?}, 0x2c2acc0?)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP(0xc0029f4908, {0x1f98160, 0xc012dee000}, 0xc000c76480)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/server.go:384 +0x111e

Oct 28 15:05:08 web01 caddy[2621539]: net/http.serverHandler.ServeHTTP({0xc0414a2f80?}, {0x1f98160?, 0xc012dee000?}, 0xc03c2f0ce8?)

Oct 28 15:05:08 web01 caddy[2621539]:         net/http/server.go:3142 +0x8e

Oct 28 15:05:08 web01 caddy[2621539]: net/http.initALPNRequest.ServeHTTP({{0x1f9bd08?, 0xc010a6b9e0?}, 0xc02ec19508?, {0xc0004b5770?}}, {0x1f98160, 0xc012dee000}, 0xc000c76480)

Oct 28 15:05:08 web01 caddy[2621539]:         net/http/server.go:3750 +0x231

Oct 28 15:05:08 web01 caddy[2621539]: golang.org/x/net/http2.(*serverConn).runHandler(0x448ebd?, 0x0?, 0x0?, 0xc0490e41c0?)

Oct 28 15:05:08 web01 caddy[2621539]:         golang.org/x/net@v0.29.0/http2/server.go:2414 +0x113

Oct 28 15:05:08 web01 caddy[2621539]: created by golang.org/x/net/http2.(*serverConn).scheduleHandler in goroutine 3874036131

Oct 28 15:05:08 web01 caddy[2621539]:         golang.org/x/net@v0.29.0/http2/server.go:2348 +0x21d

Oct 28 15:05:08 web01 caddy[2621539]: goroutine 1 [select (no cases), 18227 minutes]:

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/cmd.cmdRun({0x0?})

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/cmd/commandfuncs.go:283 +0xbfc

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/cmd.init.1.func2.WrapCommandFuncForCobra.1(0xc0005a8608, {0x1a4fb72?, 0x4?, 0x1a4fb3a?})

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/cmd/cobra.go:137 +0x2f

Oct 28 15:05:08 web01 caddy[2621539]: github.com/spf13/cobra.(*Command).execute(0xc0005a8608, {0xc00069a630, 0x3, 0x3})

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca

Oct 28 15:05:08 web01 caddy[2621539]: github.com/spf13/cobra.(*Command).ExecuteC(0x2c61ba0)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff

Oct 28 15:05:08 web01 caddy[2621539]: github.com/spf13/cobra.(*Command).Execute(...)

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/spf13/cobra@v1.8.0/command.go:1039

Oct 28 15:05:08 web01 caddy[2621539]: github.com/caddyserver/caddy/v2/cmd.Main()

Oct 28 15:05:08 web01 caddy[2621539]:         github.com/caddyserver/caddy/v2@v2.8.4/cmd/main.go:75 +0x1d8

Oct 28 15:05:08 web01 caddy[2621539]: main.main()

Oct 28 15:05:08 web01 caddy[2621539]:         caddy/main.go:15 +0xf

Oct 28 15:05:08 web01 caddy[2621539]: goroutine 12 [select, 18227 minutes]:

Nov 10 (Intro for 1st go routine, longer log attached)

Nov 10 11:29:32 web01 caddy[2314484]: fatal **error:** concurrent map read and map write

Nov 10 11:29:32 web01 caddy[2314484]: goroutine 3800443627 [running]:

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.GetVar({0x1f9bd08?, 0xc03724ac90?}, {0x1a68ef6, 0xe})

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/vars.go:323 +0x57

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:257 +0x1c6

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f9bd08?, {0x7f430fb2afd0?, 0xc01424db80?}, 0xe?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7f430fb2afd0, 0xc01424db80}, 0xc006df2b40)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/routes.go:268 +0x244

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1f86720?, {0x7f430fb2afd0?, 0xc01424db80?}, 0x2c2acc0?)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/caddyhttp.go:58 +0x29

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP(0xc0003cdb08, {0x1f98160, 0xc0046985b8}, 0xc0209e3c20)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/server.go:384 +0x111e

Nov 10 11:29:32 web01 caddy[2314484]: net/http.serverHandler.ServeHTTP({0x1a4fc00?}, {0x1f98160?, 0xc0046985b8?}, 0xc033cc79e0?)

Nov 10 11:29:32 web01 caddy[2314484]:         net/http/server.go:3142 +0x8e

Nov 10 11:29:32 web01 caddy[2314484]: net/http.initALPNRequest.ServeHTTP({{0x1f9bd08?, 0xc02b94c900?}, 0xc0211ef888?, {0xc01d9165a0?}}, {0x1f98160, 0xc0046985b8}, 0xc0209e3c20)

Nov 10 11:29:32 web01 caddy[2314484]:         net/http/server.go:3750 +0x231

Nov 10 11:29:32 web01 caddy[2314484]: golang.org/x/net/http2.(*serverConn).runHandler(0x448ebd?, 0x0?, 0x0?, 0xc00048f778?)

Nov 10 11:29:32 web01 caddy[2314484]:         golang.org/x/net@v0.29.0/http2/server.go:2414 +0x113

Nov 10 11:29:32 web01 caddy[2314484]: created by golang.org/x/net/http2.(*serverConn).scheduleHandler in goroutine 3800442958

Nov 10 11:29:32 web01 caddy[2314484]:         golang.org/x/net@v0.29.0/http2/server.go:2348 +0x21d

Nov 10 11:29:32 web01 caddy[2314484]: goroutine 1 [select (no cases), 18469 minutes]:

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/cmd.cmdRun({0x0?})

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/cmd/commandfuncs.go:283 +0xbfc

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/cmd.init.1.func2.WrapCommandFuncForCobra.1(0xc0005e2308, {0x1a4fb72?, 0x4?, 0x1a4fb3a?})

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/cmd/cobra.go:137 +0x2f

Nov 10 11:29:32 web01 caddy[2314484]: github.com/spf13/cobra.(*Command).execute(0xc0005e2308, {0xc000307d70, 0x3, 0x3})

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca

Nov 10 11:29:32 web01 caddy[2314484]: github.com/spf13/cobra.(*Command).ExecuteC(0x2c61ba0)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff

Nov 10 11:29:32 web01 caddy[2314484]: github.com/spf13/cobra.(*Command).Execute(...)

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/spf13/cobra@v1.8.0/command.go:1039

Nov 10 11:29:32 web01 caddy[2314484]: github.com/caddyserver/caddy/v2/cmd.Main()

Nov 10 11:29:32 web01 caddy[2314484]:         github.com/caddyserver/caddy/v2@v2.8.4/cmd/main.go:75 +0x1d8

Nov 10 11:29:32 web01 caddy[2314484]: main.main()

Nov 10 11:29:32 web01 caddy[2314484]:         caddy/main.go:15 +0xf

7. How can someone who is starting from scratch reproduce this behavior as minimally as possible?

Unfortunately, we could not reproduce the issue yet in any way, nor do we know how to isolate this down to the host/domain that is causing this.

We have not yet tried to down-grade to 2.7.6. and see if that happens again with the cache module, but then if it only occurs every 3 or so weeks randomly we’re not even sure if that makes sense at this point.

We would kindly ask for help to enable/change to more helpful logging details for this than the raw unqualified go stack-trace

caddy-crash-2024-11-10.log caddy-crash-2024-10-28.log

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 45 (18 by maintainers)

Most upvoted comments

We’ve also just signed up for the Sponsor Startup plan @mholt with our startup AIPRM now (almost empty repo) thanks for all you do and have done so far with your teams, and so glad to have escaped the Apache/Nginx mess 😃

Image

I figured it out, I think.

The request logging at the end of the response write so we can collect the response size. The size is then set in the replacer. The replacer is created and used per request. However – your addition of the cache handler is what’s causing the data race. Cache is inherently a data race between the cached value and the response from upstream. If you check Souin code, you’ll find there are scenarios where it spins off a goroutine to fetch new value from upstream while fetching the value from cache and catching the winner. Both goroutines share the same ResponseWriter, hence same replacer, thus causing the panic when those values are read/write concurrently by the cache handler.

I still don’t think the mutexes in Caddy are needed because we already fixed one of them (for the replacer). Your issues stem from how the cache handler behaves. If you can try vanilla Caddy with the -race that’d be great.

Pinging @darkweak for the cache/souin logic.

Adding to what Matt says and probably mentioned earlier, the output of the race detector, i.e. with -race, will say exactly where the concurrent read/write are happening. It eliminates the guess work you’re currently doing.

Since we disagree on this, I guess we’ll just keep counting how many times Caddy takes down a dozen production websites and services and backend-APIs down in the next days & weeks based on this “policy”.

That tone is insulting.

I have that policy because I’m a volunteer. I offer my time to the project in the open so that anyone who has similar issues may find their answers from the discussions and troubleshooting that happens in the open, in searchable/indexable parts of the internet. I have to draw the line somewhere to limit things and to keep a healthy open-source/life balance.

If you want private support then you should consider sponsoring the project https://caddyserver.com/support and Matt will be able to prioritize helping you.

Configs are not private information. Post your config here if you want to get help.

You’re describing a race in map access. The odd thing is, the subject map is scoped per HTTP request:

https://github.com/caddyserver/caddy/blob/7088605cc11c52c2777ab613dfc5c2a9816006e4/modules/caddyhttp/vars.go#L316-L324

I, for one, cannot imagine 2 HTTP requests sharing the same context, so maybe we’re missing something. If you can share minimal config, maybe we can all look at reproducing it with, perhaps, Vegeta.

New DATA RACE from the current 2.7.6. instrumented rwmutex already showed up over the weekend finally on QA system

vars.go line 146 is here

so this one is from the v2.7.6-rwmutexplus2 tag we put to QA first last week, not from my local dev @mholt and also shows the prev. metioned race with the (very much used) reverse proxy code I believe

{"level":"info","ts":1731672966.188622,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar matchers.error' (goroutine 19731)"}
{"level":"info","ts":1731672966.4276166,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19732)"}
{"level":"info","ts":1731672966.4309962,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (0 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19732)"}
{"level":"info","ts":1731672966.4499252,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19732)"}
{"level":"info","ts":1731672966.4739034,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19732)"}
{"level":"info","ts":1731672966.4794927,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19732)"}
{"level":"info","ts":1731672966.481423,"msg":"[VarsRWMutex] WARNING #2: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 103 - 2x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19732)"}
{"level":"info","ts":1731672966.4874957,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19732)"}
{"level":"info","ts":1731672966.499189,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar matchers.error' (goroutine 19732)"}
==================
WARNING: DATA RACE
Read at 0x00c0218f4200 by goroutine 1148452:
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*responseRecorder).Size()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/responsewriter.go:205 +0x2f
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).logRequest()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/server.go:703 +0x21d
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP.func2()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/server.go:328 +0xc4
  runtime.deferreturn()
      /usr/local/go/1.21.8/src/runtime/panic.go:477 +0x30
  net/http.serverHandler.ServeHTTP()
      /usr/local/go/1.21.8/src/net/http/server.go:2938 +0x2a1
  net/http.(*conn).serve()
      /usr/local/go/1.21.8/src/net/http/server.go:2009 +0xc24
  net/http.(*Server).Serve.func3()
      /usr/local/go/1.21.8/src/net/http/server.go:3086 +0x4f

Previous write at 0x00c0218f4200 by goroutine 1148647:
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*hijackedConn).ReadFrom()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/responsewriter.go:259 +0xe5
  io.copyBuffer()
      /usr/local/go/1.21.8/src/io/io.go:416 +0x1be
  io.Copy()
      /usr/local/go/1.21.8/src/io/io.go:389 +0xa4
  github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy.switchProtocolCopier.copyFromBackend()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/reverseproxy/streaming.go:535 +0x32
  github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy.(*Handler).handleUpgradeResponse.func9()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/reverseproxy/streaming.go:136 +0x6b

Goroutine 1148452 (running) created at:
  net/http.(*Server).Serve()
      /usr/local/go/1.21.8/src/net/http/server.go:3086 +0x86c
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).Start.func3()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/app.go:515 +0x4f

Goroutine 1148647 (finished) created at:
  github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy.(*Handler).handleUpgradeResponse()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/reverseproxy/streaming.go:136 +0x118a
  github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy.(*Handler).finalizeResponse()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/reverseproxy/reverseproxy.go:934 +0x134
  github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy.(*Handler).reverseProxy()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/reverseproxy/reverseproxy.go:920 +0x1ead
  github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy.(*Handler).proxyLoopIteration()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/reverseproxy/reverseproxy.go:549 +0x1291
  github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy.(*Handler).ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/reverseproxy/reverseproxy.go:456 +0x45e
  github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:331 +0x81
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:300 +0x471
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp/rewrite.Rewrite.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/rewrite/rewrite.go:137 +0x4c1
  github.com/caddyserver/caddy/v2/modules/caddyhttp/rewrite.(*Rewrite).ServeHTTP()
      <autogenerated>:1 +0x12b
  github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:331 +0x81
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:300 +0x471
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Subroute).ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/subroute.go:74 +0x96
  github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:331 +0x81
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:300 +0x471
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:268 +0x3a1
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp/encode.(*Encode).ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/encode/encode.go:138 +0x425
  github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:331 +0x81
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp/caddyauth.Authentication.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyauth/caddyauth.go:98 +0x7dd
  github.com/caddyserver/caddy/v2/modules/caddyhttp/caddyauth.(*Authentication).ServeHTTP()
      <autogenerated>:1 +0x98
  github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:331 +0x81
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:300 +0x471
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:268 +0x3a1
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp/rewrite.Rewrite.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/rewrite/rewrite.go:137 +0x4c1
  github.com/caddyserver/caddy/v2/modules/caddyhttp/rewrite.(*Rewrite).ServeHTTP()
      <autogenerated>:1 +0x12b
  github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:331 +0x81
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.VarsMiddleware.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/vars.go:146 +0x7c4
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*VarsMiddleware).ServeHTTP()
      <autogenerated>:1 +0x84
  github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:331 +0x81
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:300 +0x471
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Subroute).ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/subroute.go:74 +0x96
  github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:331 +0x81
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:300 +0x471
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:268 +0x3a1
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:268 +0x3a1
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:268 +0x3a1
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:268 +0x3a1
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:268 +0x3a1
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/routes.go:268 +0x3a1
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).enforcementHandler()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/server.go:429 +0x208
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).Provision.(*Server).wrapPrimaryRoute.func1()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/server.go:405 +0x68
  github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/caddyhttp.go:58 +0x47
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP()
      /LRT/go/pkg/mod/github.com/christophcemper/caddy/v2@v2.7.6-rwmutexplus2/modules/caddyhttp/server.go:341 +0x1598
  net/http.serverHandler.ServeHTTP()
      /usr/local/go/1.21.8/src/net/http/server.go:2938 +0x2a1
  net/http.(*conn).serve()
      /usr/local/go/1.21.8/src/net/http/server.go:2009 +0xc24
  net/http.(*Server).Serve.func3()
      /usr/local/go/1.21.8/src/net/http/server.go:3086 +0x4f
==================
{"level":"info","ts":1731673007.6401973,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19733)"}
{"level":"info","ts":1731673007.6514091,"logger":"http.log.access","msg":"handled request","request":{"remote_ip":"194.50.16.198","remote_port":"54502","client_ip":"194.50.16.198","proto":"HTTP/1.1","method":"GET","host":"185.111.124.119:80","uri":"/cgi-bin/index.html","headers":{"Connection":["close"]}},"bytes_read":0,"user_id":"","duration":0.002867672,"size":0,"status":308,"resp_headers":{"Server":["Caddy"],"Connection":["close"],"Location":["https://185.111.124.119/cgi-bin/index.html"],"Content-Type":[]}}
{"level":"info","ts":1731673028.889694,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19734)"}
{"level":"info","ts":1731673028.903976,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19734)"}
{"level":"info","ts":1731673028.9166713,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19734)"}
{"level":"info","ts":1731673028.9311402,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19734)"}
{"level":"info","ts":1731673028.9571898,"msg":"[VarsRWMutex] WARNING #2: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 103 - 2x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19734)"}
{"level":"info","ts":1731673028.9628122,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar matchers.error' (goroutine 19734)"}
{"level":"info","ts":1731673028.965843,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar matchers.error' (goroutine 19734)"}
{"level":"info","ts":1731673067.2807975,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19736)"}
{"level":"info","ts":1731673067.3019083,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19736)"}
{"level":"info","ts":1731673067.3150997,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19736)"}
{"level":"info","ts":1731673067.325189,"msg":"[VarsRWMutex] WARNING #1: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 51 - 1x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19736)"}
{"level":"info","ts":1731673067.3330736,"msg":"[VarsRWMutex] WARNING #2: HOLDING ReadLock (1 readers)\n ACTIVE ReadLock took 103 - 2x exceeding timeout of 50ms - for 'GetVar client_ip' (goroutine 19736)"}


That’s very interesting – thanks for posting that. I’ll look into it tomorrow; but in the meantime, it’s pretty clear from looking at the referenced lines, that it isn’t the same as the fatal concurrent map read/write originally posted about, unfortunately.

I would be expecting a data race with one of the reads or writes at github.com/caddyserver/caddy/v2@v2.8.4/modules/caddyhttp/vars.go:323 (v2.8.4) based on the original post. Do you have any data races with the file vars.go?

Yes, I agree - here’s one DATA RACE I just got when starting up on my Mac Studio @mholt

from this build version based on v2.8.4

{"level":"info","ts":1731625446.609313,"msg":"ENV: RWMutexPlus (VarsRWMutex, 134ms) - RWMUTEXTPLUS_VERBOSELEVEL (2)"}
{"level":"info","ts":1731625446.609357,"msg":"ENV: RWMutexPlus (VarsRWMutex, 134ms) - RWMUTEXTPLUS_DEBUGLEVEL (1)"}
{"level":"info","ts":1731625446.609385,"msg":"ENV: RWMutexPlus (VarsRWMutex, 134ms) - RWMUTEXTPLUS_TIMEOUT (50ms)"}
{"level":"info","ts":1731625446.6094022,"msg":"ENV: RWMutexPlus (VarsRWMutex, 50ms) - RWMUTEXTPLUS_CALLERINFOLINES (4)"}
{"level":"info","ts":1731625446.609427,"msg":"ENV: RWMutexPlus (VarsRWMutex, 50ms) - RWMUTEXTPLUS_CALLERINFOSKIP (4)"}
{"level":"info","ts":1731625446.609448,"msg":"ENV: RWMutexPlus (VarsRWMutex, 50ms) - RWMUTEXTPLUS_DEBUGLEVEL (1)"}
{"level":"info","ts":1731625446.609466,"msg":"ENV: RWMutexPlus (VarsRWMutex, 50ms) - RWMUTEXTPLUS_VERBOSELEVEL (2)"}
{"level":"info","ts":1731625446.610605,"msg":"using config from file","file":"./CaddyfileDEV"}
{"level":"info","ts":1731625446.7271528,"msg":"adapted config to JSON","adapter":"caddyfile"}
{"level":"warn","ts":1731625446.727189,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"./CaddyfileDEV","line":185}
{"level":"info","ts":1731625446.818974,"msg":"redirected default logger","from":"stderr","to":"/Users/christophc/Workspace/AIPRM2/App/log/debug.log"}
==================
WARNING: DATA RACE
Read at 0x00c0009ae1b0 by goroutine 105:
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).CaddyModule()
      <autogenerated>:1 +0x38
  github.com/caddyserver/caddy/v2/modules/caddyevents.(*App).Emit()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddyevents/app.go:228 +0x4cc
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).onEvent()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddytls/tls.go:691 +0xe4
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).onEvent-fm()
      <autogenerated>:1 +0x28
  github.com/caddyserver/certmagic.(*Config).emit()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:1258 +0x6c4
  github.com/caddyserver/certmagic.(*Config).renewCert.func2()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:827 +0x454
  github.com/caddyserver/certmagic.doWithRetry()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/async.go:104 +0x214
  github.com/caddyserver/certmagic.(*Config).renewCert()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:974 +0x57c
  github.com/caddyserver/certmagic.(*Config).RenewCertAsync()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:762 +0x59c
  github.com/caddyserver/certmagic.(*Config).manageOne.func2()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:463 +0x5a0
  github.com/caddyserver/certmagic.(*jobManager).worker()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/async.go:73 +0x164
  github.com/caddyserver/certmagic.(*jobManager).Submit.func2()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/async.go:50 +0x34

Previous write at 0x00c0009ae1b0 by main goroutine:
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).keepStorageClean()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddytls/tls.go:603 +0xcc
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).Start()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddytls/tls.go:329 +0x234
  github.com/caddyserver/caddy/v2.run.func4()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:513 +0x138
  github.com/caddyserver/caddy/v2.run()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:529 +0x804
  github.com/caddyserver/caddy/v2.unsyncedDecodeAndRun()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:343 +0x234
  github.com/caddyserver/caddy/v2.changeConfig()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:234 +0x800
  github.com/caddyserver/caddy/v2.Load()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:133 +0xac
  github.com/caddyserver/caddy/v2/cmd.cmdRun()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/commandfuncs.go:231 +0x71c
  github.com/caddyserver/caddy/v2/cmd.init.1.func2.WrapCommandFuncForCobra.func1()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/cobra.go:137 +0x3c
  github.com/spf13/cobra.(*Command).execute()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xb18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x4b8
  github.com/spf13/cobra.(*Command).Execute()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x1bc
  github.com/caddyserver/caddy/v2/cmd.Main()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/main.go:75 +0x1a8
  main.main()
      /Users/christophc/Workspace/common/CaddyLRT/build_tmp/buildenv_2024-11-14-0312.1171402475/main.go:16 +0x20

Goroutine 105 (running) created at:
  github.com/caddyserver/certmagic.(*jobManager).Submit()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/async.go:50 +0x33c
  github.com/caddyserver/certmagic.(*Config).manageOne()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:481 +0x6d0
  github.com/caddyserver/certmagic.(*Config).manageAll()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:381 +0x21c
  github.com/caddyserver/certmagic.(*Config).ManageAsync()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:338 +0x2d8
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).Manage()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddytls/tls.go:432 +0x268
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).automaticHTTPSPhase2()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddyhttp/autohttps.go:743 +0x1ac
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).Start()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddyhttp/app.go:535 +0x9b0
  github.com/caddyserver/caddy/v2.run.func4()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:513 +0x138
  github.com/caddyserver/caddy/v2.run()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:529 +0x804
  github.com/caddyserver/caddy/v2.unsyncedDecodeAndRun()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:343 +0x234
  github.com/caddyserver/caddy/v2.changeConfig()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:234 +0x800
  github.com/caddyserver/caddy/v2.Load()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:133 +0xac
  github.com/caddyserver/caddy/v2/cmd.cmdRun()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/commandfuncs.go:231 +0x71c
  github.com/caddyserver/caddy/v2/cmd.init.1.func2.WrapCommandFuncForCobra.func1()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/cobra.go:137 +0x3c
  github.com/spf13/cobra.(*Command).execute()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xb18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x4b8
  github.com/spf13/cobra.(*Command).Execute()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x1bc
  github.com/caddyserver/caddy/v2/cmd.Main()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/main.go:75 +0x1a8
  main.main()
      /Users/christophc/Workspace/common/CaddyLRT/build_tmp/buildenv_2024-11-14-0312.1171402475/main.go:16 +0x20
==================
==================
WARNING: DATA RACE
Read at 0x00c0009ae1b8 by goroutine 105:
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).CaddyModule()
      <autogenerated>:1 +0x38
  github.com/caddyserver/caddy/v2/modules/caddyevents.(*App).Emit()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddyevents/app.go:271 +0xb80
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).onEvent()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddytls/tls.go:691 +0xe4
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).onEvent-fm()
      <autogenerated>:1 +0x28
  github.com/caddyserver/certmagic.(*Config).emit()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:1258 +0x6c4
  github.com/caddyserver/certmagic.(*Config).renewCert.func2()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:827 +0x454
  github.com/caddyserver/certmagic.doWithRetry()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/async.go:104 +0x214
  github.com/caddyserver/certmagic.(*Config).renewCert()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:974 +0x57c
  github.com/caddyserver/certmagic.(*Config).RenewCertAsync()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:762 +0x59c
  github.com/caddyserver/certmagic.(*Config).manageOne.func2()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:463 +0x5a0
  github.com/caddyserver/certmagic.(*jobManager).worker()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/async.go:73 +0x164
  github.com/caddyserver/certmagic.(*jobManager).Submit.func2()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/async.go:50 +0x34

Previous write at 0x00c0009ae1b8 by main goroutine:
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).keepStorageClean()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddytls/tls.go:604 +0x124
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).Start()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddytls/tls.go:329 +0x234
  github.com/caddyserver/caddy/v2.run.func4()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:513 +0x138
  github.com/caddyserver/caddy/v2.run()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:529 +0x804
  github.com/caddyserver/caddy/v2.unsyncedDecodeAndRun()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:343 +0x234
  github.com/caddyserver/caddy/v2.changeConfig()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:234 +0x800
  github.com/caddyserver/caddy/v2.Load()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:133 +0xac
  github.com/caddyserver/caddy/v2/cmd.cmdRun()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/commandfuncs.go:231 +0x71c
  github.com/caddyserver/caddy/v2/cmd.init.1.func2.WrapCommandFuncForCobra.func1()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/cobra.go:137 +0x3c
  github.com/spf13/cobra.(*Command).execute()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xb18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x4b8
  github.com/spf13/cobra.(*Command).Execute()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x1bc
  github.com/caddyserver/caddy/v2/cmd.Main()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/main.go:75 +0x1a8
  main.main()
      /Users/christophc/Workspace/common/CaddyLRT/build_tmp/buildenv_2024-11-14-0312.1171402475/main.go:16 +0x20

Goroutine 105 (running) created at:
  github.com/caddyserver/certmagic.(*jobManager).Submit()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/async.go:50 +0x33c
  github.com/caddyserver/certmagic.(*Config).manageOne()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:481 +0x6d0
  github.com/caddyserver/certmagic.(*Config).manageAll()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:381 +0x21c
  github.com/caddyserver/certmagic.(*Config).ManageAsync()
      /Users/christophc/go/pkg/mod/github.com/caddyserver/certmagic@v0.21.3/config.go:338 +0x2d8
  github.com/caddyserver/caddy/v2/modules/caddytls.(*TLS).Manage()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddytls/tls.go:432 +0x268
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).automaticHTTPSPhase2()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddyhttp/autohttps.go:743 +0x1ac
  github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).Start()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/modules/caddyhttp/app.go:535 +0x9b0
  github.com/caddyserver/caddy/v2.run.func4()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:513 +0x138
  github.com/caddyserver/caddy/v2.run()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:529 +0x804
  github.com/caddyserver/caddy/v2.unsyncedDecodeAndRun()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:343 +0x234
  github.com/caddyserver/caddy/v2.changeConfig()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:234 +0x800
  github.com/caddyserver/caddy/v2.Load()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/caddy.go:133 +0xac
  github.com/caddyserver/caddy/v2/cmd.cmdRun()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/commandfuncs.go:231 +0x71c
  github.com/caddyserver/caddy/v2/cmd.init.1.func2.WrapCommandFuncForCobra.func1()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/cobra.go:137 +0x3c
  github.com/spf13/cobra.(*Command).execute()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xb18
  github.com/spf13/cobra.(*Command).ExecuteC()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x4b8
  github.com/spf13/cobra.(*Command).Execute()
      /Users/christophc/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x1bc
  github.com/caddyserver/caddy/v2/cmd.Main()
      /Users/christophc/Workspace/common/CaddyLRT/caddy-fork/cmd/main.go:75 +0x1a8
  main.main()
      /Users/christophc/Workspace/common/CaddyLRT/build_tmp/buildenv_2024-11-14-0312.1171402475/main.go:16 +0x20
==================

The newer logs look nice, thanks for the updates – but I’m still looking for the output of the race detector. I saw the one in souin, but it sounds like you’re saying there is still a race in Caddy itself, and I can’t diagnose it without the output of the race detector.

The reason I hesitate to add more mutexing to the vars handler is because handlers generally shouldn’t be accessing that concurrently during a request. I’d like to pin down exactly what’s happening using the race detector output.

3/ Replacer middleware is also suffering from DATA RACEs - and is not yet sync’ed by me

I believe this was fixed in v2.8.x. as of commit https://github.com/caddyserver/caddy/commit/e7336cc3bfcf60eb775c60509d521e92a5a3b6fe.

I’m mostly away from my desk on the weekends, so I have yet to catch up on the whole discussion as it’s only Monday morning here, but:

  • It’s fairly obvious from inspection that what Francis said is correct: a handler is concurrently accessing the vars map during a request. (Each request has its own vars map.)
  • A simple “fix” is indeed possible as I mentioned, assuming the use of the proper APIs GetVar() and SetVar(), to use a mutex to sync access to the map.
  • However, I’m not sure that is most correct. A handler performing concurrent work on the request is usually the sign of a bug, thus concurrent access is not generally supported in HTTP handler chains.
  • The most correct thing to do would be to eliminate concurrency on shared state while handling the request.
  • Seeing your config and, if possible, the characteristics of the request (URI, headers, etc) would be helpful to know what other handlers are in the chain and which ones are being invoked.
  • Francis is a volunteer, as he says, and prefers that help given benefits the public community, so receiving information in private isn’t helpful there.
  • As a full-time maintainer, I’m happy to offer help and receive through private venues, but I’m so busy that I can only afford to do this for sponsors (at least the Indie Pro tier, which offers some basic occasional email support). If you or your company are already a sponsor, I apologize, GitHub isn’t showing the Sponsor badge for me with your account. You can sign up to be a sponsor at the tier that best fits your company, or post your config here in public. You can redact credentials though; and remember that hostnames are considered addresses, not secrets (we often need the actual domain strings to troubleshoot and trace code execution because there is logic depending on the characteristics of the actual hostnames).
  • You can enable the race detector when you build Caddy to pinpoint what is actually going on next time this happens. Use the -race flag, or, if using xcaddy, set XCADDY_RACE_DETECTOR=1. Note that this will be less performant but will print exactly where the concurrency is happening. I think it’s unlikely to be happening in Caddy core modules (we don’t use concurrency during a request handler chain, except technically in the reverse proxy for full duplex streaming; but anyway, I would be surprised if our code is triggering this since we haven’t seen this before – but I can’t rule it out). The race detector will show us.

Anyway, I’m mostly repeating what Francis already said, but I hope this offers some clarity. If you can post the config (and ideally the request too) here, even if we can’t reliably reproduce it, we can likely have a better sense of the problem and offer a viable solution rather than guessing. (We try not to guess here when possible.)

What is the full output of caddy build-info and caddy list-modules?

Since we disagree on this, I guess we’ll just keep counting how many times Caddy takes down a dozen production websites and services and backend-APIs down in the next days & weeks based on this “policy”.

Without a config we cannot minimally reproduce this, and therefore can’t fix this. Please share a minimally reproducing config.

Go itself now uses the latest version of the runtime when building. It downloads the latest patch version that matches the minimum minor version requirement. See https://tip.golang.org/doc/toolchain

Thanks; a quick preliminary look suggests this may be a simple fix in the vars middleware. Will get back to this soon 🙂