core: /info 500s until leader is elected
jbowens opened this issue · 0 comments
jbowens commented
To reproduce:
- Start up a new core.
- Configure it via the dashboard.
- Look at the logs.
The logs show a flurry of /info
requests 500-ing. I think these are multiple /info requests from dashboard that are queueing up, waiting for the chain/core handler to be setup. There's a race then between the chain/core handler being installed and the first attempt at becoming leader.
We could
- make one initial attempt at becoming leader synchronously in
leader.Run
. - return 503 status code if there is no leader in the leader table
app=cored buildtag=? processID=chain-mba.local-9429-a600bf5217cbd9853e8b reqid=d112a8e73874d0c0f0d7 at=api.go:385 t=2017-04-26T17:38:34.126375317Z status=500 chaincode=CH000 path=/info error="could not fetch leader address: sql: no rows in result set"
/Users/jackson/src/chain/core/leader/leader.go:58 - chain/core/leader.(*Leader).Address
/Users/jackson/src/chain/core/api.go:341 - chain/core.(*API).forwardToLeader
/Users/jackson/src/chain/core/core.go:58 - chain/core.(*API).info
/Users/jackson/src/chain/core/api.go:180 - chain/core.(*API).(chain/core.info)-fm
/usr/local/go/src/runtime/asm_amd64.s:515 - runtime.call64
/usr/local/go/src/reflect/value.go:434 - reflect.Value.call
/usr/local/go/src/reflect/value.go:302 - reflect.Value.Call
/Users/jackson/src/chain/net/http/httpjson/handler.go:60 - chain/net/http/httpjson.(*handler).ServeHTTP
/usr/local/go/src/net/http/server.go:2238 - net/http.(*ServeMux).ServeHTTP
/Users/jackson/src/chain/core/api.go:192 - chain/core.(*API).buildHandler.func5
app=cored buildtag=? processID=chain-mba.local-9429-a600bf5217cbd9853e8b at=leader.go:102 t=2017-04-26T17:38:34.129994263Z message="I am the core leader"