cloudfoundry/gorouter — pull request #30 by jackfengibm (2014-02-26 18:56:04+00:00)
Title: Race conditions in registry and process_status of gorouter

* fixed race condition in updating registry.updateAt record of gorouter
* fixed race condition in updatig process_status of gorouter
====================================
Here is error which led to the fixes on component.go and process_status.go:

==================
WARNING: DATA RACE
Read by goroutine 148:
github.com/cloudfoundry/gorouter/common.UpdateVarz()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/common/component.go:55 +0xd7
github.com/cloudfoundry/gorouter/common.func·003()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/common/component.go:147 +0x1c2
net/http.HandlerFunc.ServeHTTP()
/usr/local/go/src/pkg/net/http/server.go:1149 +0x4b
net/http.(*ServeMux).ServeHTTP()
/usr/local/go/src/pkg/net/http/server.go:1416 +0x145
github.com/cloudfoundry/gorouter/common/http.(*BasicAuth).ServeHTTP()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/common/http/basic_auth.go:44 +0x123
net/http.serverHandler.ServeHTTP()
/usr/local/go/src/pkg/net/http/server.go:1517 +0x1c8
net/http.(*conn).serve()
/usr/local/go/src/pkg/net/http/server.go:1096 +0xc6f
gosched0()
/usr/local/go/src/pkg/runtime/proc.c:1218 +0x9f

Previous write by goroutine 139:
github.com/cloudfoundry/gorouter/common.(*ProcessStatus).Update()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/common/process_status.go:47 +0xca
github.com/cloudfoundry/gorouter/common.func·006()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/common/process_status.go:31 +0xa0
gosched0()
/usr/local/go/src/pkg/runtime/proc.c:1218 +0x9f

Goroutine 148 (running) created at:
net/http.(*Server).Serve()
/usr/local/go/src/pkg/net/http/server.go:1564 +0x29c
net/http.(*Server).ListenAndServe()
/usr/local/go/src/pkg/net/http/server.go:1532 +0xbe
github.com/cloudfoundry/gorouter/common.(*VcapComponent).ListenAndServe()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/common/component.go:169 +0x59b
gosched0()
/usr/local/go/src/pkg/runtime/proc.c:1218 +0x9f

====================================
====================================
And this is the error which led to the fixes on registry.go:

==================
WARNING: DATA RACE
Write by goroutine 9:
github.com/cloudfoundry/gorouter/registry.(*CFRegistry).pauseStaleTracker()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/registry/registry.go:208 +0xd8
github.com/cloudfoundry/gorouter/registry.(*CFRegistry).PruneStaleDroplets()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/registry/registry.go:147 +0x66
github.com/cloudfoundry/gorouter/registry.(*CFRegistry).checkAndPrune()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/registry/registry.go:222 +0xcc
gosched0()
/usr/local/go/src/pkg/runtime/proc.c:1218 +0x9f

Previous write by goroutine 39:
github.com/cloudfoundry/gorouter/registry.(*CFRegistry).Register()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/registry/registry.go:91 +0x2ff
github.com/cloudfoundry/gorouter/router.func·003()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/router/router.go:175 +0x39f
github.com/cloudfoundry/gorouter/router.func·007()
/Users/jackfeng/go/src/github.com/cloudfoundry/gorouter/router/router.go:281 +0x689
gosched0()
/usr/local/go/src/pkg/runtime/proc.c:1218 +0x9f