File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ package embed
1616
1717import (
1818 "context"
19+ "errors"
1920 "fmt"
2021 "io"
2122 defaultLog "log"
@@ -100,7 +101,12 @@ func (sctx *serveCtx) serve(
100101 gopts ... grpc.ServerOption ,
101102) (err error ) {
102103 logger := defaultLog .New (io .Discard , "etcdhttp" , 0 )
103- <- s .ReadyNotify ()
104+
105+ select {
106+ case <- s .StoppingNotify ():
107+ return errors .New ("server is stopping" )
108+ case <- s .ReadyNotify ():
109+ }
104110
105111 sctx .lg .Info ("ready to serve client requests" )
106112
Original file line number Diff line number Diff line change @@ -2284,6 +2284,21 @@ func (s *EtcdServer) monitorClusterVersions() {
22842284func (s * EtcdServer ) monitorStorageVersion () {
22852285 lg := s .Logger ()
22862286 monitor := serverversion .NewMonitor (lg , NewServerVersionAdapter (s ))
2287+
2288+ // The field "storageVersion" in Meta bucket was introduced in 3.6.
2289+ // It doesn't exist in 3.5 and older versions. We depend on fields
2290+ // "confState" and "term" to identify 3.5, as the two fields were
2291+ // introduced in 3.5.
2292+ // But the field "confState" is only guaranteed to be populated
2293+ // after the member fully bootstraps itself. So we need to wait
2294+ // for the etcdserver ready for serve client requests here.
2295+ select {
2296+ case <- s .StoppingNotify ():
2297+ return
2298+ case <- s .ReadyNotify ():
2299+ }
2300+ lg .Info ("monitorStorageVersion: start running" )
2301+
22872302 for {
22882303 select {
22892304 case <- time .After (monitorVersionInterval ):
You can’t perform that action at this time.
0 commit comments