Skip to content
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

*: Support LOCK/UNLOCK TABLES feature #10343

Merged
merged 61 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
6ef6a15
update go.mod for parser
crazycs520 Apr 26, 2019
5ccef6f
add lock tables and test in table_test, todo: add locks info to session
crazycs520 Apr 29, 2019
1cd6c41
add lock tables and test in table_test, todo: add locks info to session
crazycs520 Apr 29, 2019
bbeef6c
release lock before add lock and refactor struct
crazycs520 Apr 30, 2019
b937cd2
todo: support lock/unlock mutitable and check table lock after privil…
crazycs520 Apr 30, 2019
7415cf7
support lock multi-table lock but with diff schema version, todo: add…
crazycs520 May 3, 2019
07c721c
add check after privilege check
crazycs520 May 4, 2019
6fa4022
Merge branch 'master' of https://github.com/pingcap/tidb into table_lock
crazycs520 May 5, 2019
d7f73a6
fix unit test
crazycs520 May 5, 2019
68b611d
refine code
crazycs520 May 5, 2019
9e507a4
fix show privilege check table lock and not support lock table in INF…
crazycs520 May 5, 2019
86c9be1
add more unit test
crazycs520 May 5, 2019
12d6fe1
add mutex in session.lockedtables to avoid concurrent problem
crazycs520 May 5, 2019
45e9120
add none unique table check in lock tables
crazycs520 May 5, 2019
9b4841a
fix ci
crazycs520 May 5, 2019
afd98cf
add table lock test in transaction
crazycs520 May 5, 2019
7886732
add concurrent lock tables test
crazycs520 May 5, 2019
3419f71
remove blank line
crazycs520 May 5, 2019
9e4b024
add todo: clean table lock when tidb-server was kill -9
crazycs520 May 5, 2019
2126cd8
add lock unsupport schema check,test and add comments
crazycs520 May 6, 2019
fee3c99
Merge branch 'master' into table_lock
crazycs520 May 6, 2019
5b1a0ca
fix table lock bug in drop table/schema, truncate table bug
crazycs520 May 7, 2019
8263814
fix test
crazycs520 May 7, 2019
461fffd
Merge branch 'master' of https://github.com/pingcap/tidb into table_lock
crazycs520 May 20, 2019
919ac2c
fix test
crazycs520 May 20, 2019
196eeeb
add config field to control enable table feature
crazycs520 May 20, 2019
a9f8008
Merge branch 'master' of https://github.com/pingcap/tidb into table_lock
crazycs520 May 21, 2019
5345a68
remove redundant file
crazycs520 May 21, 2019
1e81a14
Merge branch 'master' of https://github.com/pingcap/tidb into table_lock
crazycs520 May 27, 2019
52239f9
address comment
crazycs520 May 27, 2019
116803a
address comment and add test
crazycs520 May 29, 2019
521493b
Merge branch 'master' of https://github.com/pingcap/tidb into table_lock
crazycs520 May 29, 2019
4bb0cdc
address comment
crazycs520 May 31, 2019
6500545
add todo comment
crazycs520 May 31, 2019
2338305
remove redundant code
crazycs520 May 31, 2019
1246312
address comment
crazycs520 Jun 3, 2019
e317505
Merge branch 'master' of https://github.com/pingcap/tidb into table_lock
crazycs520 Jun 3, 2019
871ccbc
address comment
crazycs520 Jun 5, 2019
d25ad49
add comment
crazycs520 Jun 5, 2019
dcd6e5b
ignore table not exists error for drop table not exists
crazycs520 Jun 5, 2019
e97b08d
refine comment
crazycs520 Jun 5, 2019
276b6c2
refine code
crazycs520 Jun 5, 2019
b05c612
address comment
crazycs520 Jun 5, 2019
5bdc187
address comment
crazycs520 Jun 6, 2019
926ca8d
add comment
crazycs520 Jun 6, 2019
2daf292
fix ci
crazycs520 Jun 6, 2019
055f73f
update parser in go.mod
crazycs520 Jun 10, 2019
ed419cf
Merge branch 'master' of https://github.com/pingcap/tidb into table_lock
crazycs520 Jun 10, 2019
d04d8cf
fix race by avoid race
crazycs520 Jun 10, 2019
101102a
Address comment
crazycs520 Jun 17, 2019
af345bd
try to remove mutex
crazycs520 Jun 17, 2019
58b4fb1
Merge branch 'master' of https://github.com/pingcap/tidb into table_lock
crazycs520 Jun 17, 2019
a316a7b
address comment
crazycs520 Jun 17, 2019
099ca8f
fix operate database when session holding table locks.
crazycs520 Jun 17, 2019
dcfe7f6
fix ci
crazycs520 Jun 17, 2019
dcf5793
Merge branch 'master' into table_lock
crazycs520 Jun 17, 2019
7f2b121
Merge branch 'master' into table_lock
crazycs520 Jun 17, 2019
c511160
add todo
crazycs520 Jun 18, 2019
f5c3df1
Merge branch 'master' into table_lock
crazycs520 Jun 18, 2019
defcb0a
fix data race in test
crazycs520 Jun 18, 2019
db760e1
Merge branch 'master' into table_lock
crazycs520 Jun 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type Config struct {
// TreatOldVersionUTF8AsUTF8MB4 is use to treat old version table/column UTF8 charset as UTF8MB4. This is for compatibility.
// Currently not support dynamic modify, because this need to reload all old version schema.
TreatOldVersionUTF8AsUTF8MB4 bool `toml:"treat-old-version-utf8-as-utf8mb4" json:"treat-old-version-utf8-as-utf8mb4"`
// 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 @@ -321,6 +324,7 @@ var defaultConf = Config{
EnableStreaming: false,
CheckMb4ValueInUTF8: true,
TreatOldVersionUTF8AsUTF8MB4: true,
EnableTableLock: false,
TxnLocalLatches: TxnLocalLatches{
Enabled: true,
Capacity: 2048000,
Expand Down Expand Up @@ -574,6 +578,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
3 changes: 3 additions & 0 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ 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

# 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 @@ -60,6 +60,7 @@ unrecognized-option-test = true

_, err = f.WriteString(`
token-limit = 0
enable-table-lock = true
[performance]
[tikv-client]
commit-timeout="41s"
Expand All @@ -78,6 +79,7 @@ max-batch-size=128
c.Assert(conf.TiKVClient.CommitTimeout, Equals, "41s")
c.Assert(conf.TiKVClient.MaxBatchSize, Equals, uint(128))
c.Assert(conf.TokenLimit, Equals, uint(1000))
c.Assert(conf.EnableTableLock, IsTrue)
c.Assert(f.Close(), IsNil)
c.Assert(os.Remove(configFile), IsNil)

Expand Down
Loading