-
Notifications
You must be signed in to change notification settings - Fork 727
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
server: refine package server error log format in RFC #2713
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import ( | |
"github.com/pingcap/kvproto/pkg/metapb" | ||
"github.com/pingcap/kvproto/pkg/pdpb" | ||
"github.com/pingcap/log" | ||
"github.com/tikv/pd/pkg/errs" | ||
"github.com/tikv/pd/server/cluster" | ||
"github.com/tikv/pd/server/config" | ||
"github.com/tikv/pd/server/core" | ||
|
@@ -209,9 +210,9 @@ func (h *Handler) AddScheduler(name string, args ...string) error { | |
} | ||
log.Info("create scheduler", zap.String("scheduler-name", s.GetName())) | ||
if err = c.AddScheduler(s, args...); err != nil { | ||
log.Error("can not add scheduler", zap.String("scheduler-name", s.GetName()), zap.Error(err)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove the |
||
log.Error("can not add scheduler", zap.String("scheduler-name", s.GetName()), errs.ZapError(errs.ErrSchedulerOperation, err)) | ||
} else if err = h.opt.Persist(c.GetStorage()); err != nil { | ||
log.Error("can not persist scheduler config", zap.Error(err)) | ||
log.Error("can not persist scheduler config", errs.ZapError(errs.ErrSavePersistOptions, err)) | ||
} | ||
return err | ||
} | ||
|
@@ -223,7 +224,7 @@ func (h *Handler) RemoveScheduler(name string) error { | |
return err | ||
} | ||
if err = c.RemoveScheduler(name); err != nil { | ||
log.Error("can not remove scheduler", zap.String("scheduler-name", name), zap.Error(err)) | ||
log.Error("can not remove scheduler", zap.String("scheduler-name", name), errs.ZapError(errs.ErrSchedulerOperation, err)) | ||
} | ||
return err | ||
} | ||
|
@@ -238,9 +239,9 @@ func (h *Handler) PauseOrResumeScheduler(name string, t int64) error { | |
} | ||
if err = c.PauseOrResumeScheduler(name, t); err != nil { | ||
if t == 0 { | ||
log.Error("can not resume scheduler", zap.String("scheduler-name", name), zap.Error(err)) | ||
log.Error("can not resume scheduler", zap.String("scheduler-name", name), errs.ZapError(errs.ErrSchedulerOperation, err)) | ||
} else { | ||
log.Error("can not pause scheduler", zap.String("scheduler-name", name), zap.Error(err)) | ||
log.Error("can not pause scheduler", zap.String("scheduler-name", name), errs.ZapError(errs.ErrSchedulerOperation, err)) | ||
} | ||
} | ||
return err | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ import ( | |
"github.com/pingcap/kvproto/pkg/pdpb" | ||
"github.com/pingcap/log" | ||
"github.com/pingcap/sysutil" | ||
"github.com/tikv/pd/pkg/errs" | ||
"github.com/tikv/pd/pkg/etcdutil" | ||
"github.com/tikv/pd/pkg/grpcutil" | ||
"github.com/tikv/pd/pkg/logutil" | ||
|
@@ -419,7 +420,7 @@ func (s *Server) Close() { | |
s.hbStreams.Close() | ||
} | ||
if err := s.storage.Close(); err != nil { | ||
log.Error("close storage meet error", zap.Error(err)) | ||
log.Error("close storage meet error", errs.ZapError(errs.ErrStorageClose, err)) | ||
} | ||
|
||
// Run callbacks | ||
|
@@ -438,7 +439,7 @@ func (s *Server) IsClosed() bool { | |
// Run runs the pd server. | ||
func (s *Server) Run() error { | ||
go StartMonitor(s.ctx, time.Now, func() { | ||
log.Error("system time jumps backward") | ||
log.Error("system time jumps backward", errs.ZapError(errs.ErrSystemTime)) | ||
timeJumpBackCounter.Inc() | ||
}) | ||
if err := s.startEtcd(s.ctx); err != nil { | ||
|
@@ -717,7 +718,7 @@ func (s *Server) GetConfig() *config.Config { | |
log.Error("failed to decode scheduler config", | ||
zap.String("config", configs[i]), | ||
zap.String("scheduler", sche), | ||
zap.Error(err)) | ||
errs.ZapError(errs.ErrDecodeConfig, err)) | ||
continue | ||
} | ||
payload[sche] = config | ||
|
@@ -749,7 +750,7 @@ func (s *Server) SetScheduleConfig(cfg config.ScheduleConfig) error { | |
log.Error("failed to update schedule config", | ||
zap.Reflect("new", cfg), | ||
zap.Reflect("old", old), | ||
zap.Error(err)) | ||
errs.ZapError(errs.ErrSavePersistOptions, err)) | ||
return err | ||
} | ||
log.Info("schedule config is updated", zap.Reflect("new", cfg), zap.Reflect("old", old)) | ||
|
@@ -795,7 +796,7 @@ func (s *Server) SetReplicationConfig(cfg config.ReplicationConfig) error { | |
log.Error("failed to update replication config", | ||
zap.Reflect("new", cfg), | ||
zap.Reflect("old", old), | ||
zap.Error(err)) | ||
errs.ZapError(errs.ErrSavePersistOptions, err)) | ||
return err | ||
} | ||
log.Info("replication config is updated", zap.Reflect("new", cfg), zap.Reflect("old", old)) | ||
|
@@ -833,7 +834,7 @@ func (s *Server) SetPDServerConfig(cfg config.PDServerConfig) error { | |
log.Error("failed to update PDServer config", | ||
zap.Reflect("new", cfg), | ||
zap.Reflect("old", old), | ||
zap.Error(err)) | ||
errs.ZapError(errs.ErrSavePersistOptions, err)) | ||
return err | ||
} | ||
log.Info("PD server config is updated", zap.Reflect("new", cfg), zap.Reflect("old", old)) | ||
|
@@ -849,7 +850,7 @@ func (s *Server) SetLabelPropertyConfig(cfg config.LabelPropertyConfig) error { | |
log.Error("failed to update label property config", | ||
zap.Reflect("new", cfg), | ||
zap.Reflect("old", &old), | ||
zap.Error(err)) | ||
errs.ZapError(errs.ErrSavePersistOptions, err)) | ||
return err | ||
} | ||
log.Info("label property config is updated", zap.Reflect("new", cfg), zap.Reflect("old", old)) | ||
|
@@ -867,7 +868,7 @@ func (s *Server) SetLabelProperty(typ, labelKey, labelValue string) error { | |
zap.String("labelKey", labelKey), | ||
zap.String("labelValue", labelValue), | ||
zap.Reflect("config", s.persistOptions.GetLabelPropertyConfig()), | ||
zap.Error(err)) | ||
errs.ZapError(errs.ErrSavePersistOptions, err)) | ||
return err | ||
} | ||
|
||
|
@@ -886,7 +887,7 @@ func (s *Server) DeleteLabelProperty(typ, labelKey, labelValue string) error { | |
zap.String("labelKey", labelKey), | ||
zap.String("labelValue", labelValue), | ||
zap.Reflect("config", s.persistOptions.GetLabelPropertyConfig()), | ||
zap.Error(err)) | ||
errs.ZapError(errs.ErrSavePersistOptions, err)) | ||
return err | ||
} | ||
|
||
|
@@ -913,7 +914,7 @@ func (s *Server) SetClusterVersion(v string) error { | |
log.Error("failed to update cluster version", | ||
zap.String("old-version", old.String()), | ||
zap.String("new-version", v), | ||
zap.Error(err)) | ||
errs.ZapError(errs.ErrSavePersistOptions, err)) | ||
return err | ||
} | ||
log.Info("cluster version is updated", zap.String("new-version", v)) | ||
|
@@ -1020,7 +1021,7 @@ func (s *Server) SetReplicationModeConfig(cfg config.ReplicationModeConfig) erro | |
log.Error("failed to update replication mode config", | ||
zap.Reflect("new", cfg), | ||
zap.Reflect("old", &old), | ||
zap.Error(err)) | ||
errs.ZapError(errs.ErrSavePersistOptions, err)) | ||
return err | ||
} | ||
log.Info("replication mode config is updated", zap.Reflect("new", cfg), zap.Reflect("old", old)) | ||
|
@@ -1038,7 +1039,7 @@ func (s *Server) SetReplicationModeConfig(cfg config.ReplicationModeConfig) erro | |
s.persistOptions.SetReplicationModeConfig(old) | ||
revertErr := s.persistOptions.Persist(s.storage) | ||
if revertErr != nil { | ||
log.Error("failed to revert replication mode persistent config", zap.Error(err)) | ||
log.Error("failed to revert replication mode persistent config", errs.ZapError(errs.ErrSavePersistOptions, err)) | ||
} | ||
} | ||
return err | ||
|
@@ -1064,7 +1065,7 @@ func (s *Server) leaderLoop() { | |
if leader != nil { | ||
err := s.reloadConfigFromKV() | ||
if err != nil { | ||
log.Error("reload config failed", zap.Error(err)) | ||
log.Error("reload config failed", errs.ZapError(errs.ErrLoadPersistOptions, err)) | ||
continue | ||
} | ||
syncer := s.cluster.GetRegionSyncer() | ||
|
@@ -1094,7 +1095,7 @@ func (s *Server) campaignLeader() { | |
zap.String("campaign-pd-leader-name", s.Name()), | ||
zap.String("purpose", s.member.Leadership.Purpose)) | ||
if err := s.member.Leadership.Campaign(s.cfg.LeaderLease, s.member.GetLeaderPath(), s.member.MemberValue()); err != nil { | ||
log.Error("campaign pd leader meet error", zap.Error(err)) | ||
log.Error("campaign pd leader meet error", errs.ZapError(errs.ErrCampaignLeader, err)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this is already a RFC error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. It is a local error caused by lease or etcd. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we need to wrap the third error to RFC error in |
||
return | ||
} | ||
|
||
|
@@ -1112,18 +1113,18 @@ func (s *Server) campaignLeader() { | |
|
||
log.Info("initialize the global TSO allocator") | ||
if err := s.tsoAllocator.Initialize(); err != nil { | ||
log.Error("failed to initialize the global TSO allocator", zap.Error(err)) | ||
log.Error("failed to initialize the global TSO allocator", errs.ZapError(errs.ErrCreateTSOStream, err)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. plz directly use RFC error. |
||
return | ||
} | ||
defer s.tsoAllocator.Reset() | ||
|
||
if err := s.reloadConfigFromKV(); err != nil { | ||
log.Error("failed to reload configuration", zap.Error(err)) | ||
log.Error("failed to reload configuration", errs.ZapError(errs.ErrLoadPersistOptions, err)) | ||
return | ||
} | ||
// Try to create raft cluster. | ||
if err := s.createRaftCluster(); err != nil { | ||
log.Error("failed to create raft cluster", zap.Error(err)) | ||
log.Error("failed to create raft cluster", errs.ZapError(errs.ErrCreateCluster, err)) | ||
return | ||
} | ||
defer s.stopRaftCluster() | ||
|
@@ -1153,7 +1154,7 @@ func (s *Server) campaignLeader() { | |
} | ||
case <-tsTicker.C: | ||
if err := s.tsoAllocator.UpdateTSO(); err != nil { | ||
log.Error("failed to update timestamp", zap.Error(err)) | ||
log.Error("failed to update timestamp", errs.ZapError(errs.ErrUpdateTso, err)) | ||
return | ||
} | ||
case <-ctx.Done(): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the len > 1?