@@ -330,7 +330,7 @@ func (s *Topom) GroupPromoteServer(gid int, addr string) error {
330330 }
331331}
332332
333- func (s * Topom ) tryFixReplicationRelationships (ctx * context , recoveredGroupServers []* redis.ReplicationState , masterOffGroupLen int ) {
333+ func (s * Topom ) tryFixReplicationRelationships (ctx * context , recoveredGroupServers []* redis.ReplicationState ) {
334334 for _ , state := range recoveredGroupServers {
335335 log .Infof ("group-[%d] try to fix server[%v-%v] replication relationship" , state .GroupID , state .Index , state .Addr )
336336 group , err := ctx .getGroup (state .GroupID )
@@ -346,7 +346,7 @@ func (s *Topom) tryFixReplicationRelationships(ctx *context, recoveredGroupServe
346346 continue
347347 }
348348
349- err = s .tryFixReplicationRelationship (group , state .Server , state , masterOffGroupLen )
349+ err = s .tryFixReplicationRelationship (group , state .Server , state )
350350 if err != nil {
351351 log .Warnf ("group-[%d] fix server[%v] replication relationship failed, err: %v" , group .Id , state .Addr , err )
352352 continue
@@ -371,19 +371,14 @@ func (s *Topom) tryFixReplicationRelationships(ctx *context, recoveredGroupServe
371371// only fix which the old state of GroupServer is GroupServerStateOffline.
372372// It will only update the state of GroupServer to GroupServerStateNormal, If the GroupServer have right
373373// master-slave replication relationship.
374- func (s * Topom ) tryFixReplicationRelationship (group * models.Group , groupServer * models.GroupServer , state * redis.ReplicationState , masterOffGroupLen int ) (err error ) {
374+ func (s * Topom ) tryFixReplicationRelationship (group * models.Group , groupServer * models.GroupServer , state * redis.ReplicationState ) (err error ) {
375375 curMasterAddr := group .Servers [0 ].Addr
376376 if isGroupMaster (state , group ) {
377- // current server is master,
378- if models .GroupServerRole (state .Replication .Role ) == models .RoleMaster {
379- if masterOffGroupLen > 0 {
380- return nil
381- }
382- }
383-
384377 // execute the command `slaveof no one`
385- if err = promoteServerToNewMaster (state .Addr , s .config .ProductAuth ); err != nil {
386- return err
378+ if models .GroupServerRole (state .Replication .Role ) != models .RoleMaster {
379+ if err = promoteServerToNewMaster (state .Addr , s .config .ProductAuth ); err != nil {
380+ return err
381+ }
387382 }
388383 } else {
389384 // skip if it has right replication relationship
0 commit comments