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
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 45 (18 by maintainers)
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 😃
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
-racethat’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.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
mapis 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-rwmutexplus2tag 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 believeThat’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 filevars.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
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.
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:
GetVar()andSetVar(), to use a mutex to sync access to the map.-raceflag, or, if using xcaddy, setXCADDY_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-infoandcaddy 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 🙂