Skip to content

Commit

Permalink
Merge branch 'master' into fix_tiny_bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot[bot] authored Feb 18, 2024
2 parents dd880b4 + 5a37b80 commit 0ef9c94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions tools/pd-heartbeat-bench/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
defaultReportRatio = 1
defaultRound = 0
defaultSample = false
defaultInitialVersion = 1

defaultLogFormat = "text"
)
Expand All @@ -40,6 +41,7 @@ type Config struct {

Security configutil.SecurityConfig `toml:"security" json:"security"`

InitEpochVer uint64 `toml:"epoch-ver" json:"epoch-ver"`
StoreCount int `toml:"store-count" json:"store-count"`
HotStoreCount int `toml:"hot-store-count" json:"hot-store-count"`
RegionCount int `toml:"region-count" json:"region-count"`
Expand All @@ -66,6 +68,7 @@ func NewConfig() *Config {
fs.StringVar(&cfg.Security.CAPath, "cacert", "", "path of file that contains list of trusted TLS CAs")
fs.StringVar(&cfg.Security.CertPath, "cert", "", "path of file that contains X509 certificate in PEM format")
fs.StringVar(&cfg.Security.KeyPath, "key", "", "path of file that contains X509 key in PEM format")
fs.Uint64Var(&cfg.InitEpochVer, "epoch-ver", 1, "the initial epoch version value")

return cfg
}
Expand Down Expand Up @@ -142,6 +145,9 @@ func (c *Config) Adjust(meta *toml.MetaData) {
if !meta.IsDefined("sample") {
c.Sample = defaultSample
}
if !meta.IsDefined("epoch-ver") {
c.InitEpochVer = defaultInitialVersion
}
}

// Validate is used to validate configurations
Expand Down
12 changes: 10 additions & 2 deletions tools/pd-heartbeat-bench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ const (
capacity = 4 * units.TiB
)

var clusterID uint64
var (
clusterID uint64
maxVersion uint64 = 1
)

func newClient(ctx context.Context, cfg *config.Config) (pdpb.PDClient, error) {
tlsConfig, err := cfg.Security.ToTLSConfig()
Expand Down Expand Up @@ -204,7 +207,7 @@ func (rs *Regions) init(cfg *config.Config, options *config.Options) {
Id: id,
StartKey: codec.GenerateTableKey(int64(i)),
EndKey: codec.GenerateTableKey(int64(i + 1)),
RegionEpoch: &metapb.RegionEpoch{ConfVer: 2, Version: 1},
RegionEpoch: &metapb.RegionEpoch{ConfVer: 2, Version: maxVersion},
},
ApproximateSize: bytesUnit,
Interval: &pdpb.TimeInterval{
Expand Down Expand Up @@ -264,6 +267,9 @@ func (rs *Regions) update(cfg *config.Config, options *config.Options) {
for _, i := range rs.updateEpoch {
region := rs.regions[i]
region.Region.RegionEpoch.Version += 1
if region.Region.RegionEpoch.Version > maxVersion {
maxVersion = region.Region.RegionEpoch.Version
}
}
// update space
for _, i := range rs.updateSpace {
Expand Down Expand Up @@ -476,6 +482,7 @@ func main() {
log.Fatal("initialize logger error", zap.Error(err))
}

maxVersion = cfg.InitEpochVer
options := config.NewOptions(cfg)
// let PD have enough time to start
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -549,6 +556,7 @@ func main() {
zap.String("average", fmt.Sprintf("%.4fs", stats.Average)),
zap.String("stddev", fmt.Sprintf("%.4fs", stats.Stddev)),
zap.String("rps", fmt.Sprintf("%.4f", stats.RPS)),
zap.Uint64("max-epoch-version", maxVersion),
)
log.Info("store heartbeat stats", zap.String("max", fmt.Sprintf("%.4fs", since)))
regions.update(cfg, options)
Expand Down

0 comments on commit 0ef9c94

Please sign in to comment.