Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix pump storage quit bug #739

Merged
merged 3 commits into from
Sep 5, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pump/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ type Server struct {
gs *grpc.Server
ctx context.Context
cancel context.CancelFunc
pullCtx context.Context
pullCancel context.CancelFunc
lichunzhu marked this conversation as resolved.
Show resolved Hide resolved
wg sync.WaitGroup
gcDuration time.Duration
triggerGC chan time.Time
Expand Down Expand Up @@ -112,7 +114,8 @@ func NewServer(cfg *Config) (*Server, error) {
if err != nil {
return nil, errors.Trace(err)
}
ctx, cancel := context.WithCancel(context.Background())
pullCtx, pullCancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(pullCtx)
clusterID := pdCli.GetClusterID(ctx)
log.Infof("clusterID of pump server is %v", clusterID)

Expand Down Expand Up @@ -163,6 +166,8 @@ func NewServer(cfg *Config) (*Server, error) {
gs: grpc.NewServer(grpcOpts...),
ctx: ctx,
cancel: cancel,
pullCtx: pullCtx,
pullCancel: pullCancel,
metrics: metrics,
gcDuration: time.Duration(cfg.GC) * 24 * time.Hour,
pdCli: pdCli,
Expand Down Expand Up @@ -289,7 +294,7 @@ func (s *Server) PullBinlogs(in *binlog.PullBinlogReq, stream binlog.Pump_PullBi
log.Errorf("drainer request a purged binlog (gc ts = %d), request %+v, some binlog events may be loss", gcTS, in)
}

ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(s.pullCtx)
defer cancel()
binlogs := s.storage.PullCommitBinlog(ctx, last)

Expand Down Expand Up @@ -865,6 +870,8 @@ func (s *Server) Close() {
s.commitStatus()
log.Info("commit status done")

// PullBinlogs should be stopped after commitStatus
s.pullCancel()
// stop the gRPC server
s.gs.GracefulStop()
log.Info("grpc is stopped")
Expand Down