Fix concurrent map crash in UptimePerService #132
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fatal error: concurrent map iteration and map write
goroutine 366332 [running]:
internal/runtime/maps.fatal({0x108cc23?, 0x47bc2f?})
/usr/local/go/src/runtime/panic.go:1046 +0x18
internal/runtime/maps.(*Iter).Next(0xc000b09640?)
/usr/local/go/src/internal/runtime/maps/table.go:792 +0x86
quotient/www/api.GetUptimeStatus({0x121bb10, 0xc0004fc5a0}, 0xc000210b40)
/src/www/api/graphs.go:198 +0x91b
net/http.HandlerFunc.ServeHTTP(...)
/usr/local/go/src/net/http/server.go:2322
quotient/www/middleware.Logging.func1({0x121bb10, 0xc0004fc5a0}, 0xc000210b40)
/src/www/middleware/logging.go:25 +0x2b8
net/http.HandlerFunc.ServeHTTP(...)
/usr/local/go/src/net/http/server.go:2322
quotient/www/middleware.Cors.func1({0x121bb10, 0xc0004fc5a0}, 0xc000210b40)
/src/www/middleware/cors.go:18 +0x272
quotient/www.(*Router).Start.Authentication.func2.1({0x121bb10, 0xc0004fc5a0}, 0xc000210a00)
/src/www/middleware/authentication.go:41 +0x31e
net/http.HandlerFunc.ServeHTTP(0xc00045aa80?, {0x121bb10?, 0xc0004fc5a0?}, 0xec4500?)
/usr/local/go/src/net/http/server.go:2322 +0x29
net/http.(*ServeMux).ServeHTTP(0x12?, {0x121bb10, 0xc0004fc5a0}, 0xc000210a00)
/usr/local/go/src/net/http/server.go:2861 +0x1c7
The engine goroutine was writing to se.UptimePerService in processCollectedResults while an HTTP handler was iterating the same map in GetUptimeStatus at graphs.go:198. Go's runtime detected this and killed the process.