Skip to content

Commit

Permalink
Merge pull request pingcap#3 from TszKitLo40/hackathon-file
Browse files Browse the repository at this point in the history
Hackathon file
  • Loading branch information
jyz0309 authored Dec 25, 2021
2 parents d8a48d9 + b634505 commit b3e5a78
Show file tree
Hide file tree
Showing 13 changed files with 6,138 additions and 19 deletions.
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ type Config struct {
SplitRegionMaxNum uint64 `toml:"split-region-max-num" json:"split-region-max-num"`
StmtSummary StmtSummary `toml:"stmt-summary" json:"stmt-summary"`
TopSQL TopSQL `toml:"top-sql" json:"top-sql"`
// EnableReplaySQL indicates that the TiDB is replaying the sql
EnableReplaySQL AtomicBool `toml:"enable-replay-sql" json:"enable_replay_sql"`
ReplayMetaTS int64 `toml:"replay-meta-ts" json:"replay_meta_ts"`
// RepairMode indicates that the TiDB is in the repair mode for table meta.
RepairMode bool `toml:"repair-mode" json:"repair-mode"`
RepairTableList []string `toml:"repair-table-list" json:"repair-table-list"`
Expand Down Expand Up @@ -635,6 +638,8 @@ var defaultConf = Config{
EnableTableLock: false,
DelayCleanTableLock: 0,
SplitRegionMaxNum: 1000,
EnableReplaySQL: *NewAtomicBool(false),
ReplayMetaTS: 0,
RepairMode: false,
RepairTableList: []string{},
MaxServerConnections: 0,
Expand Down
13 changes: 13 additions & 0 deletions domain/sql_replayer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package domain

import (
"os"
"path/filepath"
"strconv"
)

// GetSQLReplayerDirName returns sql replayer directory path.
// The path is related to the process id.
func GetSQLReplayerDirName() string {
return filepath.Join(os.TempDir(), "sql_replayer", strconv.Itoa(os.Getpid()))
}
1 change: 1 addition & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func RegisterMetrics() {
prometheus.MustRegister(TopSQLReportDurationHistogram)
prometheus.MustRegister(TopSQLReportDataHistogram)
prometheus.MustRegister(PDApiExecutionHistogram)
prometheus.MustRegister(ReplayDropCounter)

tikvmetrics.InitMetrics(TiDB, TiKVClient)
tikvmetrics.RegisterMetrics()
Expand Down
8 changes: 8 additions & 0 deletions metrics/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ var (
Help: "Bucketed histogram of all pd api execution time (s)",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 524s
}, []string{LblType})

ReplayDropCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "replay",
Name: "drop_total",
Help: "The number of record which dropped when replaying",
})
)

// ExecuteErrorToLabel converts an execute error to label.
Expand Down
Loading

0 comments on commit b3e5a78

Please sign in to comment.