allow reads on disconnected followers (#121)
This commit is contained in:
parent
e2357eac3e
commit
cb062bded4
@ -84,6 +84,7 @@ type Controller struct {
|
|||||||
lives map[*liveBuffer]bool
|
lives map[*liveBuffer]bool
|
||||||
lcond *sync.Cond
|
lcond *sync.Cond
|
||||||
fcup bool // follow caught up
|
fcup bool // follow caught up
|
||||||
|
fcuponce bool // follow caught up once
|
||||||
shrinking bool // aof shrinking flag
|
shrinking bool // aof shrinking flag
|
||||||
shrinklog [][]string // aof shrinking log
|
shrinklog [][]string // aof shrinking log
|
||||||
hooks map[string]*Hook // hook name
|
hooks map[string]*Hook // hook name
|
||||||
@ -492,7 +493,7 @@ func (c *Controller) handleInputCommand(conn *server.Conn, msg *server.Message,
|
|||||||
// read operations
|
// read operations
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
defer c.mu.RUnlock()
|
defer c.mu.RUnlock()
|
||||||
if c.config.FollowHost != "" && !c.fcup {
|
if c.config.FollowHost != "" && !c.fcuponce {
|
||||||
return writeErr(errors.New("catching up to leader"))
|
return writeErr(errors.New("catching up to leader"))
|
||||||
}
|
}
|
||||||
case "follow", "readonly", "config":
|
case "follow", "readonly", "config":
|
||||||
|
@ -218,6 +218,7 @@ func (c *Controller) followStep(host string, port int, followc uint64) error {
|
|||||||
if caughtUp {
|
if caughtUp {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
c.fcup = true
|
c.fcup = true
|
||||||
|
c.fcuponce = true
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
log.Info("caught up")
|
log.Info("caught up")
|
||||||
}
|
}
|
||||||
@ -241,6 +242,7 @@ func (c *Controller) followStep(host string, port int, followc uint64) error {
|
|||||||
caughtUp = true
|
caughtUp = true
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
c.fcup = true
|
c.fcup = true
|
||||||
|
c.fcuponce = true
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
log.Info("caught up")
|
log.Info("caught up")
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ func (c *Controller) cmdServer(msg *server.Message) (res string, err error) {
|
|||||||
if c.config.FollowHost != "" {
|
if c.config.FollowHost != "" {
|
||||||
m["following"] = fmt.Sprintf("%s:%d", c.config.FollowHost, c.config.FollowPort)
|
m["following"] = fmt.Sprintf("%s:%d", c.config.FollowHost, c.config.FollowPort)
|
||||||
m["caught_up"] = c.fcup
|
m["caught_up"] = c.fcup
|
||||||
|
m["caught_up_once"] = c.fcuponce
|
||||||
}
|
}
|
||||||
m["http_transport"] = c.http
|
m["http_transport"] = c.http
|
||||||
m["pid"] = os.Getpid()
|
m["pid"] = os.Getpid()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user