fatal error: concurrent map writes
zx8 opened this issue · 2 comments
zx8 commented
I am testing out Souin as a Caddy plugin with the following Caddyfile:
{
cache {
ttl 10s
allowed_http_verbs GET
nuts {
path /tmp/cache
}
}
order cache before rewrite
}
http://127.0.0.1:8080 {
cache {
timeout {
backend 20s
}
}
request_header -Cache-Control
request_header Content-Encoding gzip
header >Cache-Control public
header -Pragma
header -Expires
reverse_proxy http://127.0.0.1:3000 {
transport http {
read_timeout 20s
response_header_timeout 20s
}
}
}
(I'm experimenting with the Cache-Control
header behavior, so ignore the fact that things look a little strange at the moment.)
I set up a simple server on port 3000 that responds with a JSON payload, with a delay of 3 seconds to simulate network latency. I then reverse proxied traffic to this server, sending 10 requests in parallel to my Caddy listener on port 8080.
After a few requests, my Caddy server crashed with a "concurrent map writes" error:
2023/10/30 13:40:58.596 INFO http.handlers.cache Reused response from concurrent request with the key GET-http-localhost:8080-/data
2023/10/30 13:41:08.586 INFO http.handlers.cache Reused response from concurrent request with the key GET-http-localhost:8080-/data
2023/10/30 13:41:08.594 INFO http.handlers.cache Reused response from concurrent request with the key GET-http-localhost:8080-/data
2023/10/30 13:41:08.602 INFO http.handlers.cache Reused response from concurrent request with the key GET-http-localhost:8080-/data
2023/10/30 13:41:18.184 INFO http.handlers.cache Reused response from concurrent request with the key GET-http-localhost:8080-/data
2023/10/30 13:41:26.908 INFO http.handlers.cache Reused response from concurrent request with the key GET-http-localhost:8080-/data
2023/10/30 13:41:26.908 INFO http.handlers.cache Reused response from concurrent request with the key GET-http-localhost:8080-/data
fatal error: concurrent map writes