Skip to content

Commit

Permalink
avoid batching too much while send logs
Browse files Browse the repository at this point in the history
  • Loading branch information
absolute8511 committed May 9, 2018
1 parent e8d9425 commit 514e49b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion node/log_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
errInvalidRemoteCluster = errors.New("remote cluster is not valid")
errInvalidNamespace = errors.New("namespace is not valid")
rpcTimeout = time.Second * 5
sendLogTimeout = time.Second * 30
)

type ccAPIClient struct {
Expand Down Expand Up @@ -182,7 +183,7 @@ func (s *RemoteLogSender) doSendOnce(r []*BatchInternalRaftRequest) error {
if nodeLog.Level() >= common.LOG_DETAIL {
nodeLog.Debugf("sending log : %v", addr, in.String())
}
ctx, cancel := context.WithTimeout(context.Background(), rpcTimeout)
ctx, cancel := context.WithTimeout(context.Background(), sendLogTimeout)
defer cancel()
rpcErr, err := c.ApplyRaftReqs(ctx, in)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion node/syncer_learner.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,12 @@ func (sm *logSyncerSM) handlerRaftLogs() {
for {
handled := false
var err error
sendCh := sm.sendCh
if len(raftLogs) > logSendBufferLen*2 {
sendCh = nil
}
select {
case req := <-sm.sendCh:
case req := <-sendCh:
last = req
raftLogs = append(raftLogs, req)
if nodeLog.Level() > common.LOG_DETAIL {
Expand Down

0 comments on commit 514e49b

Please sign in to comment.