Skip to content

Commit

Permalink
Merge pull request #23 from kqzh/fix_leader_change_log
Browse files Browse the repository at this point in the history
  • Loading branch information
kqzh authored Nov 29, 2022
2 parents 96646b8 + 7ac492b commit c3263d6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/clients/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func NewMeta(config *MetaConfig) (*NebulaMeta, error) {

// Connect to meta service by given meta address
// We will reconnect when:
// 1. the meta service leader changed
// 2. get individual info from individual meta service, such as dir info
// 1. the meta service leader changed
// 2. get individual info from individual meta service, such as dir info
func connect(metaAddr, agentAddr *nebula.HostAddr) (*meta.MetaServiceClient, error) {
addr := utils.StringifyAddr(metaAddr)
log.WithField("meta address", addr).Info("try to connect meta service")
Expand Down Expand Up @@ -127,6 +127,7 @@ func (m *NebulaMeta) heartbeat() error {
GitInfoSha: []byte(m.config.GitInfoSHA),
}

try := 1
// retry only when leader change
for {
resp, err := m.client.AgentHeartbeat(req)
Expand Down Expand Up @@ -162,6 +163,10 @@ func (m *NebulaMeta) heartbeat() error {
return err
}
m.client = c

log.Infof("retry heatbeat, meta leader changed, try times=%d.", try)
time.Sleep(time.Duration(try) * time.Second)
try *= 2
continue
}

Expand Down

0 comments on commit c3263d6

Please sign in to comment.