Skip to content

Commit

Permalink
*: Support LOCK/UNLOCK TABLES feature (pingcap#10343)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 committed Apr 23, 2020
1 parent 445e69b commit b860085
Show file tree
Hide file tree
Showing 23 changed files with 1,122 additions and 28 deletions.
9 changes: 9 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ type Config struct {
TreatOldVersionUTF8AsUTF8MB4 bool `toml:"treat-old-version-utf8-as-utf8mb4" json:"treat-old-version-utf8-as-utf8mb4"`
SplitRegionMaxNum uint64 `toml:"split-region-max-num" json:"split-region-max-num"`
StmtSummary StmtSummary `toml:"stmt-summary" json:"stmt-summary"`
// EnableTableLock indicate whether enable table lock.
// TODO: remove this after table lock features stable.
EnableTableLock bool `toml:"enable-table-lock" json:"enable-table-lock"`
}

// Log is the log section of config.
Expand Down Expand Up @@ -376,6 +379,7 @@ var defaultConf = Config{
AlterPrimaryKey: false,
TreatOldVersionUTF8AsUTF8MB4: true,
SplitRegionMaxNum: 1000,
EnableTableLock: false,
TxnLocalLatches: TxnLocalLatches{
Enabled: false,
Capacity: 2048000,
Expand Down Expand Up @@ -652,6 +656,11 @@ func hasRootPrivilege() bool {
return os.Geteuid() == 0
}

// TableLockEnabled uses to check whether enabled the table lock feature.
func TableLockEnabled() bool {
return GetGlobalConfig().EnableTableLock
}

// ToLogConfig converts *Log to *logutil.LogConfig.
func (l *Log) ToLogConfig() *logutil.LogConfig {
return logutil.NewLogConfig(l.Level, l.Format, l.SlowQueryFile, l.File, l.DisableTimestamp, func(config *zaplog.Config) { config.DisableErrorVerbose = l.DisableErrorStack })
Expand Down
3 changes: 3 additions & 0 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ alter-primary-key = false
# if server-version = "", the default value(original TiDB version string) is used.
server-version = ""

# enable-table-lock is used to control table lock feature. Default is false, indicate the table lock feature is disabled.
enable-table-lock = false

[log]
# Log level: debug, info, warn, error, fatal.
level = "info"
Expand Down
2 changes: 2 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ alter-primary-key = true
split-region-max-num=10000
server-version = "test_version"
max-index-length = 3080
enable-table-lock = true
[performance]
txn-entry-count-limit=2000
txn-total-size-limit=2000
Expand Down Expand Up @@ -115,6 +116,7 @@ history-size=100
c.Assert(conf.StmtSummary.RefreshInterval, Equals, 100)
c.Assert(conf.StmtSummary.HistorySize, Equals, 100)
c.Assert(conf.MaxIndexLength, Equals, 3080)
c.Assert(conf.EnableTableLock, IsTrue)
c.Assert(f.Close(), IsNil)
c.Assert(os.Remove(configFile), IsNil)

Expand Down
Loading

0 comments on commit b860085

Please sign in to comment.