-
Notifications
You must be signed in to change notification settings - Fork 726
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
*:Rollback config in store when kv.persist failed #1476
Changes from 16 commits
b966728
b263e13
3af8fe3
7c02023
bc77251
c677fd2
98f9c4b
5abed59
8e1ec51
a77a952
3a758c3
237f5a5
892d1b7
19a566b
b5fbb9d
5548cdc
ea2da65
2441a70
800ed08
300ac33
8a090f4
fbb7cc8
54e34c0
28689dc
bd2754c
2f777cc
6ad3899
51e9451
21c62e4
4b64562
0ec5424
4db8982
0446e27
b710e24
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 |
---|---|---|
|
@@ -536,6 +536,11 @@ func (s *Server) SetScheduleConfig(cfg ScheduleConfig) error { | |
old := s.scheduleOpt.load() | ||
s.scheduleOpt.store(&cfg) | ||
if err := s.scheduleOpt.persist(s.kv); err != nil { | ||
s.scheduleOpt.store(old) | ||
log.Error("schedule config updated failed", | ||
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. How about changing the error message to 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. Sure. 👌 |
||
zap.Reflect("new", cfg), | ||
zap.Reflect("old", old), | ||
zap.Error(err)) | ||
return err | ||
} | ||
log.Info("schedule config is updated", zap.Reflect("new", cfg), zap.Reflect("old", old)) | ||
|
@@ -557,6 +562,11 @@ func (s *Server) SetReplicationConfig(cfg ReplicationConfig) error { | |
old := s.scheduleOpt.rep.load() | ||
s.scheduleOpt.rep.store(&cfg) | ||
if err := s.scheduleOpt.persist(s.kv); err != nil { | ||
s.scheduleOpt.rep.store(old) | ||
log.Error("replication config updated failed", | ||
zap.Reflect("new", cfg), | ||
zap.Reflect("old", old), | ||
zap.Error(err)) | ||
return err | ||
} | ||
log.Info("replication config is updated", zap.Reflect("new", cfg), zap.Reflect("old", old)) | ||
|
@@ -568,6 +578,11 @@ func (s *Server) SetPDServerConfig(cfg PDServerConfig) error { | |
old := s.scheduleOpt.loadPDServerConfig() | ||
s.scheduleOpt.pdServerConfig.Store(&cfg) | ||
if err := s.scheduleOpt.persist(s.kv); err != nil { | ||
s.scheduleOpt.pdServerConfig.Store(old) | ||
log.Error("PDServer config updated failed", | ||
zap.Reflect("new", cfg), | ||
zap.Reflect("old", old), | ||
zap.Error(err)) | ||
return err | ||
} | ||
log.Info("PD server config is updated", zap.Reflect("new", cfg), zap.Reflect("old", old)) | ||
|
@@ -605,12 +620,23 @@ func (s *Server) SetNamespaceConfig(name string, cfg NamespaceConfig) error { | |
old := s.scheduleOpt.ns[name].load() | ||
n.store(&cfg) | ||
if err := s.scheduleOpt.persist(s.kv); err != nil { | ||
s.scheduleOpt.ns[name].store(old) | ||
log.Error("namespace config updated failed", | ||
zap.String("name", name), | ||
zap.Reflect("new", cfg), | ||
zap.Reflect("old", old), | ||
zap.Error(err)) | ||
return err | ||
} | ||
log.Info("namespace config is updated", zap.String("name", name), zap.Reflect("new", cfg), zap.Reflect("old", old)) | ||
} else { | ||
s.scheduleOpt.ns[name] = newNamespaceOption(&cfg) | ||
if err := s.scheduleOpt.persist(s.kv); err != nil { | ||
s.scheduleOpt.ns[name].store(&NamespaceConfig{}) | ||
log.Error("namespace config added failed", | ||
zap.String("name", name), | ||
zap.Reflect("new", cfg), | ||
zap.Error(err)) | ||
return err | ||
} | ||
log.Info("namespace config is added", zap.String("name", name), zap.Reflect("new", cfg)) | ||
|
@@ -622,8 +648,12 @@ func (s *Server) SetNamespaceConfig(name string, cfg NamespaceConfig) error { | |
func (s *Server) DeleteNamespaceConfig(name string) error { | ||
if n, ok := s.scheduleOpt.ns[name]; ok { | ||
cfg := n.load() | ||
delete(s.scheduleOpt.ns, name) | ||
s.scheduleOpt.ns[name].store(&NamespaceConfig{}) | ||
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 not just use delete? 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. Delete is not atomic, It may cause 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. But this way may get error config? all default is zero. 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. If 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. got it. |
||
if err := s.scheduleOpt.persist(s.kv); err != nil { | ||
s.scheduleOpt.ns[name].store(cfg) | ||
log.Error("namespace config deleted failed", | ||
zap.String("name", name), | ||
zap.Error(err)) | ||
return err | ||
} | ||
log.Info("namespace config is deleted", zap.String("name", name), zap.Reflect("config", *cfg)) | ||
|
@@ -636,6 +666,13 @@ func (s *Server) SetLabelProperty(typ, labelKey, labelValue string) error { | |
s.scheduleOpt.SetLabelProperty(typ, labelKey, labelValue) | ||
err := s.scheduleOpt.persist(s.kv) | ||
if err != nil { | ||
s.scheduleOpt.DeleteLabelProperty(typ, labelKey, labelValue) | ||
log.Error("label property config updated failed", | ||
zap.String("typ", typ), | ||
zap.String("labelKey", labelKey), | ||
zap.String("labelValue", labelValue), | ||
zap.Reflect("config", s.scheduleOpt.loadLabelPropertyConfig()), | ||
zap.Error(err)) | ||
return err | ||
} | ||
log.Info("label property config is updated", zap.Reflect("config", s.scheduleOpt.loadLabelPropertyConfig())) | ||
|
@@ -647,6 +684,13 @@ func (s *Server) DeleteLabelProperty(typ, labelKey, labelValue string) error { | |
s.scheduleOpt.DeleteLabelProperty(typ, labelKey, labelValue) | ||
err := s.scheduleOpt.persist(s.kv) | ||
if err != nil { | ||
s.scheduleOpt.SetLabelProperty(typ, labelKey, labelValue) | ||
log.Error("label property config deleted failed", | ||
zap.String("typ", typ), | ||
zap.String("labelKey", labelKey), | ||
zap.String("labelValue", labelValue), | ||
zap.Reflect("config", s.scheduleOpt.loadLabelPropertyConfig()), | ||
zap.Error(err)) | ||
return err | ||
} | ||
log.Info("label property config is deleted", zap.Reflect("config", s.scheduleOpt.loadLabelPropertyConfig())) | ||
|
@@ -664,9 +708,15 @@ func (s *Server) SetClusterVersion(v string) error { | |
if err != nil { | ||
return err | ||
} | ||
old := s.scheduleOpt.loadClusterVersion() | ||
s.scheduleOpt.SetClusterVersion(*version) | ||
err = s.scheduleOpt.persist(s.kv) | ||
if err != nil { | ||
s.scheduleOpt.SetClusterVersion(old) | ||
log.Error("cluster version updated failed", | ||
zap.String("old-version", old.String()), | ||
zap.String("new-version", v), | ||
zap.Error(err)) | ||
return err | ||
} | ||
log.Info("cluster version is updated", zap.String("new-version", v)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,7 @@ func (s *serverTestSuite) TestRegionSyncer(c *C) { | |
c.Assert(err, IsNil) | ||
} | ||
// ensure flush to region kv | ||
time.Sleep(3 * time.Second) | ||
time.Sleep(5 * time.Second) | ||
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? 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. Once I have met the following logs in jenkins
Maybe the time isnt enough? I guess. 😀 : 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. I doubt that this change can solve this problem actually. /cc @nolouch 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. I'm not sure, maybe relate to the ci environment. 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. restore to 3s. |
||
err = leaderServer.Stop() | ||
c.Assert(err, IsNil) | ||
cluster.WaitLeader() | ||
|
@@ -113,7 +113,7 @@ func (s *serverTestSuite) TestFullSyncWithAddMember(c *C) { | |
c.Assert(err, IsNil) | ||
} | ||
// ensure flush to region kv | ||
time.Sleep(3 * time.Second) | ||
time.Sleep(5 * time.Second) | ||
// restart pd1 | ||
err = leaderServer.Stop() | ||
c.Assert(err, IsNil) | ||
|
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.
Seems not in good order. We recommend to put it with other 3rd part packages.