-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
br: add chaos testing for advancer owner #58183
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 |
---|---|---|
|
@@ -11,18 +11,21 @@ import ( | |
const ( | ||
flagBackoffTime = "backoff-time" | ||
flagTickInterval = "tick-interval" | ||
flagFullScanDiffTick = "full-scan-tick" | ||
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. removed since not used |
||
flagAdvancingByCache = "advancing-by-cache" | ||
flagTryAdvanceThreshold = "try-advance-threshold" | ||
flagCheckPointLagLimit = "check-point-lag-limit" | ||
|
||
DefaultConsistencyCheckTick = 5 | ||
DefaultTryAdvanceThreshold = 4 * time.Minute | ||
DefaultCheckPointLagLimit = 48 * time.Hour | ||
DefaultBackOffTime = 5 * time.Second | ||
DefaultTickInterval = 12 * time.Second | ||
DefaultFullScanTick = 4 | ||
DefaultAdvanceByCache = true | ||
// used for chaos testing | ||
BornChanger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
flagOwnershipCycleInterval = "ownership-cycle-interval" | ||
) | ||
|
||
const ( | ||
DefaultTryAdvanceThreshold = 4 * time.Minute | ||
DefaultCheckPointLagLimit = 48 * time.Hour | ||
BornChanger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
DefaultBackOffTime = 5 * time.Second | ||
DefaultTickInterval = 12 * time.Second | ||
|
||
// used for chaos testing, default to disable | ||
DefaultOwnershipCycleInterval = 0 | ||
) | ||
|
||
var ( | ||
|
@@ -38,6 +41,11 @@ type Config struct { | |
TryAdvanceThreshold time.Duration `toml:"try-advance-threshold" json:"try-advance-threshold"` | ||
// The maximum lag could be tolerated for the checkpoint lag. | ||
CheckPointLagLimit time.Duration `toml:"check-point-lag-limit" json:"check-point-lag-limit"` | ||
|
||
// Following configs are used in chaos testings, better not to enable in prod | ||
// | ||
// used to periodically becomes/retire advancer owner | ||
OwnershipCycleInterval time.Duration `toml:"ownership-cycle-interval" json:"ownership-cycle-interval"` | ||
} | ||
|
||
func DefineFlagsForCheckpointAdvancerConfig(f *pflag.FlagSet) { | ||
|
@@ -49,14 +57,22 @@ func DefineFlagsForCheckpointAdvancerConfig(f *pflag.FlagSet) { | |
"If the checkpoint lag is greater than how long, we would try to poll TiKV for checkpoints.") | ||
f.Duration(flagCheckPointLagLimit, DefaultCheckPointLagLimit, | ||
"The maximum lag could be tolerated for the checkpoint lag.") | ||
|
||
// used for chaos testing | ||
f.Duration(flagOwnershipCycleInterval, DefaultOwnershipCycleInterval, | ||
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. should we hide the parameter?
|
||
"The interval that the owner will retire itself") | ||
|
||
// mark hidden | ||
_ = f.MarkHidden(flagOwnershipCycleInterval) | ||
} | ||
|
||
func Default() Config { | ||
return Config{ | ||
BackoffTime: DefaultBackOffTime, | ||
TickDuration: DefaultTickInterval, | ||
TryAdvanceThreshold: DefaultTryAdvanceThreshold, | ||
CheckPointLagLimit: DefaultCheckPointLagLimit, | ||
BackoffTime: DefaultBackOffTime, | ||
TickDuration: DefaultTickInterval, | ||
TryAdvanceThreshold: DefaultTryAdvanceThreshold, | ||
CheckPointLagLimit: DefaultCheckPointLagLimit, | ||
OwnershipCycleInterval: DefaultOwnershipCycleInterval, | ||
} | ||
} | ||
|
||
|
@@ -78,6 +94,10 @@ func (conf *Config) GetFromFlags(f *pflag.FlagSet) error { | |
if err != nil { | ||
return err | ||
} | ||
conf.OwnershipCycleInterval, err = f.GetDuration(flagOwnershipCycleInterval) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,7 +149,6 @@ func TestDaemon(t *testing.T) { | |
ow.RetireOwner() | ||
req.False(ow.IsOwner()) | ||
app.AssertNotRunning(1 * time.Second) | ||
ow.CampaignOwner() | ||
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. it doesn't need to campaign again to become leader since only one node |
||
req.Eventually(func() bool { | ||
return ow.IsOwner() | ||
}, 1*time.Second, 100*time.Millisecond) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ import ( | |
"github.com/BurntSushi/toml" | ||
"github.com/pingcap/errors" | ||
zaplog "github.com/pingcap/log" | ||
logbackupconf "github.com/pingcap/tidb/br/pkg/streamhelper/config" | ||
"github.com/pingcap/tidb/pkg/parser/terror" | ||
"github.com/pingcap/tidb/pkg/util/logutil" | ||
"github.com/pingcap/tidb/pkg/util/tiflashcompute" | ||
|
@@ -458,13 +457,6 @@ func (b *AtomicBool) UnmarshalText(text []byte) error { | |
return nil | ||
} | ||
|
||
// LogBackup is the config for log backup service. | ||
// For now, it includes the embed advancer. | ||
type LogBackup struct { | ||
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. remove unused |
||
Advancer logbackupconf.Config `toml:"advancer" json:"advancer"` | ||
Enabled bool `toml:"enabled" json:"enabled"` | ||
} | ||
|
||
// Log is the log section of config. | ||
type Log struct { | ||
// Log level. | ||
|
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.
removed since not used