Skip to content

Commit

Permalink
owner: Update the interval of printing log (pingcap#4485)
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala authored and winkyao committed Sep 11, 2017
1 parent bc0f2d4 commit 8b9457b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions owner/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ import (
goctx "golang.org/x/net/context"
)

const (
newSessionRetryInterval = 200 * time.Millisecond
logIntervalCnt = int(3 * time.Second / newSessionRetryInterval)
)

// Manager is used to campaign the owner and manage the owner information.
type Manager interface {
// ID returns the ID of the manager.
Expand Down Expand Up @@ -120,6 +125,7 @@ func setManagerSessionTTL() error {
func NewSession(ctx goctx.Context, logPrefix string, etcdCli *clientv3.Client, retryCnt, ttl int) (*concurrency.Session, error) {
var err error
var etcdSession *concurrency.Session
failedCnt := 0
for i := 0; i < retryCnt; i++ {
if isContextDone(ctx) {
return etcdSession, errors.Trace(ctx.Err())
Expand All @@ -130,8 +136,11 @@ func NewSession(ctx goctx.Context, logPrefix string, etcdCli *clientv3.Client, r
if err == nil {
break
}
log.Warnf("%s failed to new session, err %v", logPrefix, err)
time.Sleep(200 * time.Millisecond)
if failedCnt%logIntervalCnt == 0 {
log.Warnf("%s failed to new session, err %v", logPrefix, err)
}
time.Sleep(newSessionRetryInterval)
failedCnt++
}
return etcdSession, errors.Trace(err)
}
Expand Down
2 changes: 1 addition & 1 deletion plan/join_reorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func findColumnIndexByGroup(groups []LogicalPlan, col *expression.Column) int {
return i
}
}
log.Errorf("Unknown columns %s, from id %s, position %d", col, col.FromID, col.Position)
log.Errorf("Unknown columns %s, from id %d, position %d", col, col.FromID, col.Position)
return -1
}

Expand Down

0 comments on commit 8b9457b

Please sign in to comment.