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 authored and lzmhhh123 committed Jan 19, 2020
1 parent e1e20eb commit bfc0481
Show file tree
Hide file tree
Showing 23 changed files with 1,125 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 @@ -97,6 +97,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 @@ -354,6 +357,7 @@ var defaultConf = Config{
AlterPrimaryKey: false,
TreatOldVersionUTF8AsUTF8MB4: true,
SplitRegionMaxNum: 1000,
EnableTableLock: false,
TxnLocalLatches: TxnLocalLatches{
Enabled: false,
Capacity: 2048000,
Expand Down Expand Up @@ -626,6 +630,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)
Expand Down
5 changes: 5 additions & 0 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ check-mb4-value-in-utf8 = true
# treat-old-version-utf8-as-utf8mb4 use for upgrade compatibility. Set to true will treat old version table/column UTF8 charset as UTF8MB4.
treat-old-version-utf8-as-utf8mb4 = true

<<<<<<< HEAD
# Maximum number of the splitting region, which is used by the split region statement.
split-region-max-num = 1000

Expand All @@ -70,6 +71,10 @@ alter-primary-key = false
# 2. the server version filled in handshake packets of MySQL Connection Protocol, see https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::Handshake for more details.
# 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
>>>>>>> 612936bbd... *: Support LOCK/UNLOCK TABLES feature (#10343)

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

Expand Down
Loading

0 comments on commit bfc0481

Please sign in to comment.