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

*: Reorganize partition: tiflash and update table | tidb-test=pr/2069 #40635

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
941 commits
Select commit Hold shift + click to select a range
4a72171
*: Fix issue 39999, used wrong column id list for checking partitions…
mjonss Dec 20, 2022
6ab3803
oomtest: add whitelist for oom test to fix flaky test (#40055)
hawkingrei Dec 20, 2022
017901d
*: extend skyline pruning diagnostic info and add extra warnings (#39…
time-and-fate Dec 20, 2022
0f3031e
ddl: add privilege check when alter table add foreign key (#40051)
crazycs520 Dec 20, 2022
5f1a739
planner: add more test cases for non-prep plan cache (#40060)
qw4990 Dec 20, 2022
806fcbf
sessionctx: disable gc aware memory track (#40019)
chrysan Dec 20, 2022
fdf335e
*: make auto-analyze killable by global memory limit (#39978)
chrysan Dec 20, 2022
5a60f7e
Linting
mjonss Dec 20, 2022
85257f3
Updated after make bazel_prepare
mjonss Dec 21, 2022
ae2d551
cpu: fix ticker to avoid close early (#40036)
hawkingrei Dec 21, 2022
a2fa187
build(deps): bump golang.org/x/time from 0.2.0 to 0.3.0 (#39912)
dependabot[bot] Dec 21, 2022
51cce45
ddl: use latest ts to read record for adding index (#40081)
tangenta Dec 21, 2022
2150c6b
executor: close recordset again (#40073)
hawkingrei Dec 21, 2022
785f515
planner: add more test cases for MPP hints (#39933)
Reminiscent Dec 21, 2022
08f23ef
planner: support set binding status by sql digest (#39517)
fzzf678 Dec 21, 2022
b4f500e
ddl: check the limitation when creating multi-valued index (#39818)
xiongjiwei Dec 21, 2022
13e2120
sysvar: allow modifying 'tidb_allow_remove_auto_inc' when SEM is ON (…
CbcWestwolf Dec 21, 2022
ad0c202
*: fix issue of multi-schema change with foreign key (#40042)
crazycs520 Dec 21, 2022
9e8a21c
planner: check the `ignore-plan-cache` hint in insert-stmt (#40080)
qw4990 Dec 21, 2022
fc3f04b
parser: support keep_order and no_keep_order hint (#39965)
Reminiscent Dec 21, 2022
47ace08
*: filter particularly errors when `truncateAsWarning` is true (#40078)
xiongjiwei Dec 21, 2022
273e7e8
Removed CI debug log
mjonss Dec 21, 2022
b086421
Cleaned PR to only have the core of the data copying parts
mjonss Dec 21, 2022
74fa4c4
Merge branch 'reorg-part-data-reorg' into reorg-part-rollback
mjonss Dec 21, 2022
b0c16cd
More cleanup of PR to only focus on reorg data copy
mjonss Dec 21, 2022
73dcf5a
Merge branch 'reorg-part-data-reorg' into reorg-part-rollback
mjonss Dec 21, 2022
0accdd8
Added check to avoid null-pointer dereferencing
mjonss Dec 21, 2022
8c914b0
Fixed nil session context
mjonss Dec 21, 2022
0678894
Cleanup
mjonss Dec 21, 2022
3a1adcd
Added Info logs for debugging in CI
mjonss Dec 21, 2022
f23a27a
more CI debug info logs + cleared a TODO
mjonss Dec 22, 2022
ecb7f50
Added one more CI debug line
mjonss Dec 22, 2022
4e43b14
metrics: add metrics for ema cpu metrics and GOGC (#40049)
hawkingrei Dec 22, 2022
0f4bd73
server: avoid reusing cached stmt ctx on cursor read (#40023)
zyguan Dec 22, 2022
aeccf77
*: optimize mpp probe (#39932)
hackersean Dec 22, 2022
985b5ec
Update ddl/partition.go
mjonss Dec 22, 2022
4adce4c
statistics: fix the sync load sql did'nt running internally (#40087)
Yisaer Dec 22, 2022
5fdd3bd
server: support download plan replayer continues capture file (#40085)
Yisaer Dec 22, 2022
5c04d78
*: support foreign key check/cascade when execute replace into statem…
crazycs520 Dec 22, 2022
bfd5e66
More cleanup of PR to only focus on reorg data copy
mjonss Dec 22, 2022
0b0c7ec
Removed checkReorgParition, it will be back in part 3.
mjonss Dec 22, 2022
b7e590c
Merge branch 'reorg-part-data-reorg' into reorg-part-rollback
mjonss Dec 22, 2022
1e0d902
Moved code to only run once instead of for every fetchRowColVal
mjonss Dec 22, 2022
60a956b
Merge branch 'reorg-part-data-reorg' into reorg-part-rollback
mjonss Dec 22, 2022
eb6fec9
Return directly on error instead of retrying workerCnt times
mjonss Dec 22, 2022
3438e00
Merge branch 'reorg-part-data-reorg' into reorg-part-rollback
mjonss Dec 22, 2022
1305687
ddl: fix issue of add foreign key too slow in big table (#40112)
crazycs520 Dec 22, 2022
251a69a
Merge remote-tracking branch 'pingcap/feature/reorganize-partition' i…
mjonss Dec 22, 2022
0a275d6
Merge branch 'reorg-part-merge-dec22' into reorg-part-data-reorg-merg…
mjonss Dec 22, 2022
2e5b311
Added reverted code needed for reorganize partition
mjonss Dec 22, 2022
53edd89
ddl: fix issue of partition table with foreign key and add more test …
crazycs520 Dec 23, 2022
18c71f4
parser: fix cast function restore (#40129)
xiongjiwei Dec 23, 2022
d2be278
ddl: set context correctly in the setDDLLabelForDiagnosis (#40090)
you06 Dec 23, 2022
0eab90d
Merge remote-tracking branch 'pingcap/feature/reorganize-partition' i…
mjonss Dec 23, 2022
14879a7
planner: move code of generating IndexMergePath to a separated file (…
qw4990 Dec 23, 2022
060f189
Merge remote-tracking branch 'pingcap/feature/reorganize-partition' i…
mjonss Dec 23, 2022
5632e4a
post merge fix, removed test
mjonss Dec 23, 2022
7c093a2
Merge branch 'reorg-part-data-reorg' into reorg-part-rollback
mjonss Dec 23, 2022
c27499e
Merge branch 'reorg-partition-double-write' into reorg-part-rollback
mjonss Dec 23, 2022
014159d
statistics: fix incorrect datetime value when loading stats (#40084)
xuyifangreeneyes Dec 23, 2022
c61ef1d
ttl: escape parameters for finish job sql (#40118)
YangKeao Dec 23, 2022
4702033
Merge fix
mjonss Dec 23, 2022
3112178
Merge branch 'reorg-partition-double-write' into reorg-part-rollback
mjonss Dec 23, 2022
dfd9dae
Removed applyTableUpdate from applyReorgPart + CI debug
mjonss Dec 23, 2022
a9c528c
Linting
mjonss Dec 23, 2022
c30a9ff
ddl: prohibit change name of partitioning column (#40147)
mjonss Dec 24, 2022
6ad990a
updateTable CI testing
mjonss Dec 24, 2022
658f9a6
More CI debugging
mjonss Dec 24, 2022
9d55834
Even more CI debugs...
mjonss Dec 25, 2022
40edc9e
More CI testing skipping oom tests
mjonss Dec 25, 2022
34c03ad
more CI debugging
mjonss Dec 25, 2022
bcf8ef1
Linting
mjonss Dec 25, 2022
ff8bd3c
more CI debug
mjonss Dec 25, 2022
1ace970
lightning: disable foreign key checks (#40032)
sleepymole Dec 26, 2022
388364d
br: recursive split batch create table when restore failure on batch …
fengou1 Dec 26, 2022
8a4b31a
store/copr: don't reset concurrency of analyze req to 2 (#40168)
xuyifangreeneyes Dec 26, 2022
3e2ca84
Removed cleaning of tidb_ddl_reorg when ddl is completed (CI testing)
mjonss Dec 26, 2022
2f6401a
build(deps): bump golang.org/x/oauth2 from 0.2.0 to 0.3.0 (#40140)
dependabot[bot] Dec 26, 2022
fc241b2
domain: revise plan replayer process log (#40126)
Yisaer Dec 26, 2022
f9d4a54
expression: impl cast as array function (#40076)
xiongjiwei Dec 26, 2022
fc714e2
session: fix tidb_enable_gc_aware_memory_track after upgrade (#40173)
chrysan Dec 26, 2022
79ab2b9
restore: Fix prealloc (#40176)
YuJuncen Dec 26, 2022
cf56bf9
More CI debug...
mjonss Dec 27, 2022
ab01065
metrics: remove Keep Alive OPM metric (#40142)
CbcWestwolf Dec 27, 2022
3c8f11d
util: fix data race in the cpu test (#40154)
hawkingrei Dec 27, 2022
20bb046
executor: move some test into writetest (#40097)
hawkingrei Dec 27, 2022
22261a0
More CI debug
mjonss Dec 27, 2022
a94cde3
planner: fix an unstable explain test case (#40199)
qw4990 Dec 27, 2022
83d275c
ddl: Refine the error message to compatible with MySQL when drop a pa…
jiyfhust Dec 27, 2022
afbef28
executor: TiFlash supports stale read (#40048)
Dec 27, 2022
32f9604
ddl: ignore internal http client goroutine in leak tests (#40190)
tangenta Dec 27, 2022
bddfc62
ddl: add more foreign key test case (#40052)
crazycs520 Dec 28, 2022
11f5c17
*: add support for -initialize-sql-file on first bootstrap (#35625)
morgo Dec 28, 2022
b268c65
*: fix PointGet will return an stale value when `tidb_enable_plan_rep…
lcwangchao Dec 28, 2022
f9af75f
planner: support converting `json_member_of` to IndexMerge to access …
qw4990 Dec 28, 2022
b196756
planner: record reasons when skipping Plan Cache (#40210)
qw4990 Dec 28, 2022
869b21d
session: Do not run telemetry loops when it's disabled in config (#40…
sunxiaoguang Dec 28, 2022
667bc4c
docs/design: REORGANIZE PARTITION design (#38246)
mjonss Dec 28, 2022
c8124a0
ddl: Disable RENAME COLUMN for partitioning columns | tidb-test=pr/20…
mjonss Dec 29, 2022
92a936e
dumpling: add foreign key e2e test (#40133)
crazycs520 Dec 29, 2022
cf34941
ttl: make the TTL compatible with dumpling, lightning and BR (#40216)
lcwangchao Dec 29, 2022
1a7b395
ttl, domain: setup a customized session pool with stats collector (#4…
YangKeao Dec 29, 2022
6dff69f
ddl: Support flashback cluster with ddl history (#40209)
Defined2014 Dec 29, 2022
875c002
lightning: add foreign key test (#40103)
crazycs520 Dec 29, 2022
b94042c
planner: refine planner code for disaggregated tiflash mode (#39813)
guo-shaoge Dec 29, 2022
ea29db5
docs: update tidb roadmap based on v6.5 (#40170)
ran-huang Dec 29, 2022
ffaf2ac
planner: remove the unnecessary skip-plan-cache flag in StmtCtx (#40235)
qw4990 Dec 30, 2022
25dd54f
ttl: fix change status sql argument (#40234)
YangKeao Dec 30, 2022
72f52f3
planner: update the plan cache strategy when expressions with paramet…
qw4990 Dec 30, 2022
0134d0b
go.mod: upgrade badger to 20221229114011 (#40236)
YangKeao Dec 30, 2022
d3b952a
executor: write multi-valued index (#40172)
xiongjiwei Dec 30, 2022
8e80e7c
expression: implement `unhex` function pushdown to tiflash (#39898)
b41sh Dec 30, 2022
b97f60d
planner: remove the unnecessary skip-plan-cache flag in StmtCtx (#40246)
qw4990 Dec 30, 2022
1b8a233
restore: set config value to default when failed to get config from t…
YuJuncen Dec 30, 2022
6131e3f
ddl: check default value again in updateColumnDefaultValue (#40230)
wjhuang2016 Dec 30, 2022
91adaaf
docs: update roadmap (#40244)
ran-huang Dec 30, 2022
f7de8be
*: remove the support of the old ddl framework (#39684)
wjhuang2016 Dec 30, 2022
94b65bd
Merge remote-tracking branch 'pingcap/master' into feature-reorganize…
mjonss Dec 30, 2022
47080d9
lightning: check peers write stall when switch-mode is disabled (#40228)
lance6716 Dec 30, 2022
702a559
ddl, parser: make generated column and expression index same as MySQL…
Defined2014 Dec 30, 2022
7ef86c3
Post merge fixes
mjonss Dec 30, 2022
7e2fa6c
Merge branch 'feature-reorganize-partition-merge-dec30' into reorg-pa…
mjonss Dec 30, 2022
ca03f9c
Changes from tidb#38738 to fix tidb_ddl_reorg conflicts
mjonss Dec 31, 2022
9ac5dff
Removed debug logs
mjonss Dec 31, 2022
25a2479
session: make plan replayer capture support prepared stmt (#40167)
Yisaer Jan 3, 2023
67a952a
expression: implement `regexp_replace` function pushdown (#40267)
xzhangxian1008 Jan 3, 2023
1bf230a
planner: supply more test for binding from history (#40242)
fzzf678 Jan 3, 2023
be8caa6
ttl: disable ttl job when recover/flashback table/database/cluster (#…
lcwangchao Jan 3, 2023
494672c
admin: impl admin check index for mv index (#40270)
xiongjiwei Jan 3, 2023
1e99fa4
Merge remote-tracking branch 'pingcap/feature/reorganize-partition' i…
mjonss Jan 3, 2023
5327d07
planner: refactor plan-cache UseCache flag (#40256)
qw4990 Jan 3, 2023
9aaa93e
test: fix data race in cast as array (#40277)
xiongjiwei Jan 3, 2023
4f1adb9
planner: support converting `json_overlaps/contains` to IndexMerge to…
qw4990 Jan 3, 2023
1f344ba
autoid_service: add unit test for the package (#40193)
tiancaiamao Jan 3, 2023
3ccff46
executor: special handling is required when an "auto id out of range"…
Dousir9 Jan 3, 2023
3e65e9b
util: gorotinue pool (#39872)
hawkingrei Jan 4, 2023
f483b39
metrics: add metrics for plan replayer and historical stats (#40271)
Yisaer Jan 4, 2023
3e6499b
sysvar: fix circular dependency in rebuildSysVarCache leading to dead…
CbcWestwolf Jan 4, 2023
e95881f
ddl: fix flaky test TestGlobalVariablesOnFlashback (#40291)
Defined2014 Jan 4, 2023
62a7133
server, tidb-server: kill auto analyze when gracefully shutting down …
xuyifangreeneyes Jan 4, 2023
7fafb6d
planner: better coordination between the ignore_plan_cache() binding …
qw4990 Jan 4, 2023
ccee532
store/copr: fix build batchCop in disaggregated tiflash mode (#40008)
guo-shaoge Jan 4, 2023
73c8cc7
ddl: persist index info after changing backfill state (#40229)
tangenta Jan 4, 2023
e7e7935
doc: update flashback doc (#40031)
Defined2014 Jan 4, 2023
cb5affb
ddl, parser: Implement the write-reorg state split task related funct…
zimulala Jan 4, 2023
95f0dc5
planner: support pushing down predicates to memory tables in prepared…
djshow832 Jan 4, 2023
6ae151a
planner: open the partial order prop push down for LIST PARTITION (#4…
winoros Jan 4, 2023
00604eb
br: fix bootstrap domain (#40307)
wjhuang2016 Jan 4, 2023
bf2cc45
br: add errch buf for checkpoint (#40166)
Leavrth Jan 4, 2023
be112dc
planner: skip plan-cache for prepared queries with `INT in (Decimals.…
qw4990 Jan 5, 2023
d027270
statistics: support historical stats dump partition table (#40310)
Yisaer Jan 5, 2023
37f045c
*: update badger (#40331)
xiongjiwei Jan 5, 2023
508b601
expression: enlarge timeout for test (#40332)
hawkingrei Jan 5, 2023
4a5a447
resourcemanger: add cpu scheduler (#39886)
hawkingrei Jan 5, 2023
5eea731
util: use go-deadlock to find deadlock (#40288)
hawkingrei Jan 5, 2023
affe126
*: support `curdate()` as column's default value | tidb-test=pr/2057…
CbcWestwolf Jan 5, 2023
7e64d04
ttl: don't schedule ttl job when EnableTTLJob is off (#40336)
YangKeao Jan 5, 2023
669ba5c
*: add warnings to slow log and slow query table (#39884)
time-and-fate Jan 5, 2023
331f69f
planner,infoschema,executor: Add tiflash fine grained shuffle support…
yibin87 Jan 6, 2023
e1a2b58
ddl: fill in original default for extra writable columns in batch ins…
YangKeao Jan 6, 2023
88842fa
ddltest: update goleak and enable race (#40357)
hawkingrei Jan 6, 2023
852fdc6
planner: let the planner can select IndexMerge on MVIndex without hin…
qw4990 Jan 6, 2023
3291b6d
makefile: enable deadlock in the with-real-tikv (#40359)
hawkingrei Jan 6, 2023
99100d4
planner: support more types to use IndexMerge to access MVIndex (#40343)
qw4990 Jan 6, 2023
6477d2b
log-backup: should set default value `gc.ratio-threshold` after pitr …
joccau Jan 6, 2023
b8490bc
domain: let plan replayer dump support recording stats mem status (#4…
Yisaer Jan 6, 2023
af968f2
docs: add TiDB Forum link and adjust link order (#39868)
luzizhuo Jan 6, 2023
43ebc64
ddl: support online create multi-valued index (#40304)
xiongjiwei Jan 6, 2023
b226dfc
ttl: add `ttl_job_interval` attribute and remove `tidb_ttl_job_interv…
YangKeao Jan 6, 2023
005c8d8
*: remove the support of the `amending transaction` (#39714)
wjhuang2016 Jan 6, 2023
f600fc6
executor: reset the related session vars for both INSERT and REPLACE …
winoros Jan 6, 2023
f9f7268
*: fix static pruning partition table in disaggregated tiflash mode (…
guo-shaoge Jan 6, 2023
b906bf9
planner: fix typo (#40367)
Dousir9 Jan 6, 2023
a9d8bfe
session: fix data race in the LazyTxn.LockKeys (#40350)
hawkingrei Jan 6, 2023
f7c87c8
build(deps): bump golang.org/x/crypto from 0.1.0 to 0.5.0 (#40379)
dependabot[bot] Jan 7, 2023
2d755a8
executor: fix data race at the ShowExec (#39817)
hawkingrei Jan 9, 2023
4a8006c
planner: fix panic during starting tidb-server if creating global bin…
Yisaer Jan 9, 2023
b477b1c
*: Supports create/alter/drop resource group (#40188)
nolouch Jan 9, 2023
408a466
session: fix deadlock when init domain failed (#40409)
Defined2014 Jan 9, 2023
83ec4b0
executor: support insert ignore/duplicate replace into with unique mu…
xiongjiwei Jan 9, 2023
199bb38
br: support reset_tiflash after ebs restoration (#40124)
3pointer Jan 9, 2023
7dbf1a5
ttl: add ttl goroutine exit log (#40416)
YangKeao Jan 9, 2023
0f838d9
planner, executor: split the range for unsigned pk of partition table…
winoros Jan 9, 2023
362defb
planner: add nil check when handling empty charset in `setUnionFlen` …
time-and-fate Jan 9, 2023
b912237
planner: support keep_order and no_keep_order hint (#40089)
Reminiscent Jan 9, 2023
e2a14ce
planner: unify the behavior of prepare/execute limit to mysql (#40360)
fzzf678 Jan 10, 2023
f5362f9
gpool: register gpool into resource manager (#40410)
hawkingrei Jan 10, 2023
9826913
ttl: Add `CommandClient` to trigger TTL job manually (#40346)
lcwangchao Jan 10, 2023
3f223b3
ttl: make ttl's group in granfana collapse by default (#40444)
lcwangchao Jan 10, 2023
be31b6c
br: reset cloud_admin and root after ebs restoration (#39986)
3pointer Jan 10, 2023
45d71af
ddl: support displaying sub-job reorg type in admin show ddl (#40387)
tangenta Jan 10, 2023
f771c67
planner: support use IndexMerge to access composite MVIndex (#40426)
qw4990 Jan 10, 2023
c4d8ed1
planner: add test cases for keep_order and no_keep_order hints (#40321)
Reminiscent Jan 10, 2023
3cb091b
statistics: change the upper bound of the out-of-range estimation to …
time-and-fate Jan 10, 2023
bb314af
docs: update CI build badages (#40324)
wuhuizuo Jan 10, 2023
46e67d2
planner: update the non-prep cacheable checker (#40446)
qw4990 Jan 10, 2023
02332b2
expression, planner: exclude concat_ws from aggresive folding constan…
YangKeao Jan 10, 2023
10f0093
keyspace: introduce keyspace conf and etcd path (#40269)
ystaticy Jan 10, 2023
ef7c8bd
Main Reorganize Partition DDL logic (moved from part 3)
mjonss Jan 10, 2023
eb033f8
Skipping two tests, to be fixed in separate PR
mjonss Jan 10, 2023
8a14d11
Update after `make bazel_prepare`
mjonss Jan 10, 2023
1c8007d
ddl: skip deleting the unmatched index key on merge (#40465)
tangenta Jan 10, 2023
cf8f683
Merge pingcap/master and pingcap/feature/reorganize-partition
mjonss Jan 10, 2023
4ae9e6d
Updated CODEOWNERS for the feature branch
mjonss Jan 10, 2023
34d9352
Merge remote-tracking branch 'pingcap/feature/reorganize-partition' i…
mjonss Jan 10, 2023
eb3df8b
Main Reorganize Partition DDL logic (moved from part 3)
mjonss Jan 10, 2023
ac6f869
Skipping two tests, to be fixed in separate PR
mjonss Jan 10, 2023
d3444e6
Update after `make bazel_prepare`
mjonss Jan 10, 2023
805553a
Merge remote-tracking branch 'origin/reorg-part-ddl-states' into reor…
mjonss Jan 10, 2023
46d4bf0
ci: add document about some task that will be triggered manually (#40…
hawkingrei Jan 11, 2023
db53a42
errno, store: fix ErrPDServerTimeout arguments (#40468)
dveeden Jan 11, 2023
eff7462
ttl: fix the TTL job reports error when primary key contains a column…
lcwangchao Jan 11, 2023
d2d33df
planner: support using DNF to construct IndexMerge to access MVIndex …
qw4990 Jan 11, 2023
668881f
executor: add partition table testcase for historical stats (#40453)
Yisaer Jan 11, 2023
caffd8d
ttl: forbid creating/altering a table with TTL options when pk contai…
lcwangchao Jan 11, 2023
e864d83
planner: make MVIndex be compatible with the `use/force index` hint (…
qw4990 Jan 11, 2023
e3f8d98
lightning: fix codecPDClient (#40496)
AmoebaProtozoa Jan 11, 2023
2cf328b
ddl: let concurrent truncate on the same table depend on the previous…
wjhuang2016 Jan 11, 2023
2f13578
statistics: fix estimation error when ranges are too many and modify …
time-and-fate Jan 11, 2023
6e220cf
Renamed the receiver of *partitionedTable to be consistently 't'
mjonss Jan 11, 2023
cefb261
executor: fix issue of KEY_COLUMN_USAGE table return wrong result abo…
crazycs520 Jan 11, 2023
7beec04
sysvar: add switch for plan replayer capture using historical stats (…
Yisaer Jan 11, 2023
defd80a
*: upgrade go1.19.5 (#40483)
hawkingrei Jan 11, 2023
f88714d
br: need init MDL variable when GetDomain (#40512)
joccau Jan 11, 2023
eb35c77
ddl: avoid commit conflicts when updating/delete from mysql.tidb_ddl_…
mjonss Jan 11, 2023
2b32037
Merge remote-tracking branch 'pingcap/master' into reorg-part-merge-j…
mjonss Jan 11, 2023
4b6f0ca
Post merge fix
mjonss Jan 11, 2023
d041912
Merge branch 'reorg-part-merge-jan10' into reorg-part-ddl-states
mjonss Jan 11, 2023
88f5ff8
Merge branch 'reorg-part-merge-jan10' into reorg-part-rollback-merge-…
mjonss Jan 11, 2023
bd7c905
Post merge fix
mjonss Jan 11, 2023
8bc3503
Post merge fix
mjonss Jan 11, 2023
5c71c3d
Renamed receiver of partitionedTable from p to t
mjonss Jan 11, 2023
8a97633
Removed TestTiflashReorgPartition test (since support will come later)
mjonss Jan 11, 2023
a3b77df
Removed non needed cast
mjonss Jan 11, 2023
e2b4ca5
bazel_prepare update
mjonss Jan 11, 2023
a0229ea
Merge branch 'reorg-part-ddl-states' into reorg-part-rollback-merge-j…
mjonss Jan 12, 2023
2578e7b
Merge remote-tracking branch 'pingcap/feature/reorganize-partition' i…
mjonss Jan 12, 2023
9cd2d19
Merge branch 'reorg-part-ddl-states' into reorg-part-rollback-merge-j…
mjonss Jan 12, 2023
6ae6ecd
Removed skipped tests (to be added back in next PR)
mjonss Jan 12, 2023
038a4e5
Explicitly add label on panic tests
mjonss Jan 12, 2023
d87a516
Added back code that does not need to be touched
mjonss Jan 12, 2023
5e94a2d
Removed non used test function
mjonss Jan 12, 2023
9f0a0c3
make bazel_prepare
mjonss Jan 12, 2023
1b09e1a
Cleanup
mjonss Jan 12, 2023
599f5dc
Implemented delete range cleanup for Reorganize Partition
mjonss Jan 12, 2023
11b62c7
update after make bazel_prepare
mjonss Jan 12, 2023
aa3bf0b
Merge branch 'reorg-part-rollback' into reorg-part-tiflash-and-update…
mjonss Jan 16, 2023
b8b5194
Fixed an index issue in StateDeleteReorg after adding test.
mjonss Jan 16, 2023
5a31388
Merge remote-tracking branch 'pingcap/feature/reorganize-partition' i…
mjonss Jan 18, 2023
1af113a
Fixed test for TiFlash and reorg partition
mjonss Jan 18, 2023
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
1 change: 1 addition & 0 deletions ddl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ go_test(
"//util/domainutil",
"//util/gcutil",
"//util/logutil",
"//util/mathutil",
"//util/mock",
"//util/sem",
"//util/sqlexec",
Expand Down
9 changes: 4 additions & 5 deletions ddl/backfilling.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func GetLeaseGoTime(currTime time.Time, lease time.Duration) types.Time {
// 1: add-index
// 2: modify-column-type
// 3: clean-up global index
// 4: reorganize partition
// 4: reorganize partition (copy data between partitions + create indexes on those new partitions)
//
// They all have a write reorganization state to back fill data into the rows existed.
// Backfilling is time consuming, to accelerate this process, TiDB has built some sub
Expand Down Expand Up @@ -610,6 +610,7 @@ func (dc *ddlCtx) sendTasksAndWait(scheduler *backfillScheduler, totalAddedCount
return errors.Trace(err)
}

// TODO: Maybe do reorgInfo.UpdateReorgMeta here too?
// nextHandle will be updated periodically in runReorgJob, so no need to update it here.
dc.getReorgCtx(reorgInfo.Job.ID).setNextKey(nextKey)
metrics.BatchAddIdxHistogram.WithLabelValues(metrics.LblOK).Observe(elapsedTime.Seconds())
Expand All @@ -624,7 +625,7 @@ func (dc *ddlCtx) sendTasksAndWait(scheduler *backfillScheduler, totalAddedCount
return nil
}

func getBatchTasks(t table.Table, reorgInfo *reorgInfo, kvRanges []kv.KeyRange, batch int) []*reorgBackfillTask {
func getBatchTasks(t table.PhysicalTable, reorgInfo *reorgInfo, kvRanges []kv.KeyRange, batch int) []*reorgBackfillTask {
batchTasks := make([]*reorgBackfillTask, 0, batch)
physicalTableID := reorgInfo.PhysicalTableID
var prefix kv.Key
Expand Down Expand Up @@ -654,13 +655,11 @@ func getBatchTasks(t table.Table, reorgInfo *reorgInfo, kvRanges []kv.KeyRange,
endKey = prefix.PrefixNext()
}

//nolint:forcetypeassert
phyTbl := t.(table.PhysicalTable)
task := &reorgBackfillTask{
id: i,
jobID: reorgInfo.Job.ID,
physicalTableID: physicalTableID,
physicalTable: phyTbl,
physicalTable: t,
priority: reorgInfo.Priority,
startKey: startKey,
endKey: endKey,
Expand Down
6 changes: 2 additions & 4 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4382,9 +4382,7 @@ PARTITION BY LIST (level) (
tk.MustContainErrMsg(`ALTER TABLE members REORGANIZE PARTITION p1800,p2000 INTO (PARTITION p2000 VALUES LESS THAN (2100))`, "[ddl:8200]Unsupported REORGANIZE PARTITION of RANGE; not adjacent partitions")
tk.MustExec(`INSERT INTO members VALUES (313, "John", "Doe", "2022-11-22", NULL)`)
tk.MustExec(`ALTER TABLE members REORGANIZE PARTITION p2000 INTO (PARTITION p2000 VALUES LESS THAN (2050))`)
// TODO: uncomment this:
//tk.MustContainErrMsg(`ALTER TABLE members REORGANIZE PARTITION p2000 INTO (PARTITION p2000 VALUES LESS THAN (2020))`, "[table:1526]Table has no partition for value 2022")
tk.MustContainErrMsg(`ALTER TABLE members REORGANIZE PARTITION p2000 INTO (PARTITION p2000 VALUES LESS THAN (2020))`, "[table:1526]Table has no partition for value 2022")
tk.MustExec(`INSERT INTO member_level (id, level) values (313, 6)`)
// TODO: uncomment this:
//tk.MustContainErrMsg(`ALTER TABLE member_level REORGANIZE PARTITION lEven INTO (PARTITION lEven VALUES IN (2,4))`, "[table:1526]Table has no partition for value 6")
tk.MustContainErrMsg(`ALTER TABLE member_level REORGANIZE PARTITION lEven INTO (PARTITION lEven VALUES IN (2,4))`, "[table:1526]Table has no partition for value 6")
}
207 changes: 205 additions & 2 deletions ddl/db_partition_test.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,8 @@ func getIntervalFromPolicy(policy []time.Duration, i int) (time.Duration, bool)

func getJobCheckInterval(job *model.Job, i int) (time.Duration, bool) {
switch job.Type {
case model.ActionAddIndex, model.ActionAddPrimaryKey, model.ActionModifyColumn:
case model.ActionAddIndex, model.ActionAddPrimaryKey, model.ActionModifyColumn,
model.ActionReorganizePartition:
return getIntervalFromPolicy(slowDDLIntervalPolicy, i)
case model.ActionCreateTable, model.ActionCreateSchema:
return getIntervalFromPolicy(fastDDLIntervalPolicy, i)
Expand Down
21 changes: 20 additions & 1 deletion ddl/ddl_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
tidbutil "github.com/pingcap/tidb/util"
"github.com/pingcap/tidb/util/dbterror"
"github.com/pingcap/tidb/util/logutil"
"github.com/pingcap/tidb/util/mathutil"
"github.com/pingcap/tidb/util/resourcegrouptag"
"github.com/pingcap/tidb/util/topsql"
topsqlstate "github.com/pingcap/tidb/util/topsql/state"
Expand Down Expand Up @@ -514,7 +515,8 @@ func jobNeedGC(job *model.Job) bool {
switch job.Type {
case model.ActionDropSchema, model.ActionDropTable, model.ActionTruncateTable, model.ActionDropIndex, model.ActionDropPrimaryKey,
model.ActionDropTablePartition, model.ActionTruncateTablePartition, model.ActionDropColumn, model.ActionModifyColumn,
model.ActionAddIndex, model.ActionAddPrimaryKey:
model.ActionAddIndex, model.ActionAddPrimaryKey,
model.ActionReorganizePartition:
return true
case model.ActionMultiSchemaChange:
for _, sub := range job.MultiSchemaInfo.SubJobs {
Expand Down Expand Up @@ -973,6 +975,7 @@ func (w *worker) runDDLJob(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64,
// by kv reset when meets a unhandled error, but the `job` modification can't.
// So make sure job state and args change is after all other checks or make sure these
// change has no effect when retrying it.
// TODO: Should this ^^ comment be updated with how to handle the tidb_ddl_reorg table?
switch job.Type {
case model.ActionCreateSchema:
ver, err = onCreateSchema(d, t, job)
Expand Down Expand Up @@ -1359,6 +1362,22 @@ func updateSchemaVersion(d *ddlCtx, t *meta.Meta, job *model.Job, multiInfos ...
diff.AffectedOpts = buildPlacementAffects(oldIDs, oldIDs)
}
}
case model.ActionReorganizePartition:
diff.TableID = job.TableID
if len(job.CtxVars) > 0 {
if droppedIDs, ok := job.CtxVars[0].([]int64); ok {
if addedIDs, ok := job.CtxVars[1].([]int64); ok {
// to use AffectedOpts we need both new and old to have the same length
maxParts := mathutil.Max[int](len(droppedIDs), len(addedIDs))
// Also initialize them to 0!
oldIDs := make([]int64, maxParts)
copy(oldIDs, droppedIDs)
newIDs := make([]int64, maxParts)
copy(newIDs, addedIDs)
diff.AffectedOpts = buildPlacementAffects(oldIDs, newIDs)
}
}
}
case model.ActionCreateTable:
diff.TableID = job.TableID
if len(job.Args) > 0 {
Expand Down
8 changes: 6 additions & 2 deletions ddl/delete_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,13 @@ func insertJobIntoDeleteRangeTable(ctx context.Context, sctx sessionctx.Context,
endKey := tablecodec.EncodeTablePrefix(tableID + 1)
elemID := ea.allocForPhysicalID(tableID)
return doInsert(ctx, s, job.ID, elemID, startKey, endKey, now, fmt.Sprintf("table ID is %d", tableID))
case model.ActionDropTablePartition, model.ActionTruncateTablePartition:
case model.ActionDropTablePartition, model.ActionTruncateTablePartition, model.ActionReorganizePartition:
var physicalTableIDs []int64
if err := job.DecodeArgs(&physicalTableIDs); err != nil {
// partInfo is not used, but is set in ReorgPartition.
// Better to have an additional argument in job.DecodeArgs since it is ignored,
// instead of having one to few, which will remove the data from the job arguments...
var partInfo model.PartitionInfo
if err := job.DecodeArgs(&physicalTableIDs, &partInfo); err != nil {
return errors.Trace(err)
}
for _, physicalTableID := range physicalTableIDs {
Expand Down
2 changes: 2 additions & 0 deletions ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,8 @@ func (w *worker) updateReorgInfo(t table.PartitionedTable, reorg *reorgInfo) (bo
}
if pid == 0 {
// Next partition does not exist, all the job done.
// TODO: Remove the ReorgMeta job?
// Or better, set to last key, since already processed!
return true, nil
}

Expand Down
70 changes: 51 additions & 19 deletions ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,9 @@ func (w *worker) onAddTablePartition(d *ddlCtx, t *meta.Meta, job *model.Job) (v
if tblInfo.TiFlashReplica != nil && tblInfo.TiFlashReplica.Available {
// For available state, the new added partition should wait it's replica to
// be finished. Otherwise the query to this partition will be blocked.
needRetry, err := checkPartitionReplica(tblInfo.TiFlashReplica.Count, addingDefinitions, d)
needRetry, err := checkPartitionReplica(tblInfo.TiFlashReplica.Count, 1, addingDefinitions, d)
if err != nil {
ver, err = convertAddTablePartitionJob2RollbackJob(d, t, job, err, tblInfo)
return ver, err
return convertAddTablePartitionJob2RollbackJob(d, t, job, err, tblInfo)
}
if needRetry {
// The new added partition hasn't been replicated.
Expand Down Expand Up @@ -250,8 +249,9 @@ func alterTableLabelRule(schemaName string, meta *model.TableInfo, ids []int64)
if err != nil {
return false, errors.Wrapf(err, "failed to notify PD label rule")
}
return true, nil
}
return true, nil
return false, nil
}

func alterTablePartitionBundles(t *meta.Meta, tblInfo *model.TableInfo, addingDefinitions []model.PartitionDefinition) ([]*placement.Bundle, error) {
Expand Down Expand Up @@ -352,12 +352,17 @@ func checkAddPartitionValue(meta *model.TableInfo, part *model.PartitionInfo) er
return nil
}

func checkPartitionReplica(replicaCount uint64, addingDefinitions []model.PartitionDefinition, d *ddlCtx) (needWait bool, err error) {
func checkPartitionReplica(replicaCount, minCount uint64, addingDefinitions []model.PartitionDefinition, d *ddlCtx) (needWait bool, err error) {
failpoint.Inject("mockWaitTiFlashReplica", func(val failpoint.Value) {
if val.(bool) {
failpoint.Return(true, nil)
}
})
failpoint.Inject("mockWaitTiFlashReplicaOK", func(val failpoint.Value) {
if val.(bool) {
failpoint.Return(false, nil)
}
})

ctx := context.Background()
pdCli := d.store.(tikv.Storage).GetRegionCache().PDClient()
Expand Down Expand Up @@ -388,29 +393,33 @@ func checkPartitionReplica(replicaCount uint64, addingDefinitions []model.Partit
if err != nil {
return needWait, errors.Trace(err)
}
tiflashPeerAtLeastOne := checkTiFlashPeerStoreAtLeastOne(stores, regionState.Meta.Peers)
tiflashPeerOK := checkTiFlashPeerStore(stores, minCount, regionState.Meta.Peers)
failpoint.Inject("ForceTiflashNotAvailable", func(v failpoint.Value) {
tiflashPeerAtLeastOne = v.(bool)
tiflashPeerOK = v.(bool)
})
// It's unnecessary to wait all tiflash peer to be replicated.
// Here only make sure that tiflash peer count > 0 (at least one).
if tiflashPeerAtLeastOne {
if tiflashPeerOK {
continue
}
needWait = true
logutil.BgLogger().Info("[ddl] partition replicas check failed in replica-only DDL state", zap.Int64("pID", pd.ID), zap.Uint64("wait region ID", region.Meta.Id), zap.Bool("tiflash peer at least one", tiflashPeerAtLeastOne), zap.Time("check time", time.Now()))
logutil.BgLogger().Info("[ddl] partition replicas check failed in replica-only DDL state", zap.Int64("pID", pd.ID), zap.Uint64("wait region ID", region.Meta.Id), zap.Bool("tiflash peer count OK", tiflashPeerOK), zap.Time("check time", time.Now()))
return needWait, nil
}
}
logutil.BgLogger().Info("[ddl] partition replicas check ok in replica-only DDL state")
return needWait, nil
}

func checkTiFlashPeerStoreAtLeastOne(stores []*metapb.Store, peers []*metapb.Peer) bool {
func checkTiFlashPeerStore(stores []*metapb.Store, minCount uint64, peers []*metapb.Peer) bool {
cnt := uint64(0)
for _, peer := range peers {
for _, store := range stores {
if peer.StoreId == store.Id && storeHasEngineTiFlashLabel(store) {
return true
cnt++
if cnt >= minCount {
return true
}
}
}
}
Expand Down Expand Up @@ -1705,11 +1714,12 @@ func (w *worker) onDropTablePartition(d *ddlCtx, t *meta.Meta, job *model.Job) (
if err != nil {
return ver, errors.Trace(err)
}
if job.Type == model.ActionAddTablePartition {
if job.Type == model.ActionAddTablePartition || job.Type == model.ActionReorganizePartition {
// It is rollbacked from adding table partition, just remove addingDefinitions from tableInfo.
physicalTableIDs, pNames, rollbackBundles := rollbackAddingPartitionInfo(tblInfo)
err = infosync.PutRuleBundlesWithDefaultRetry(context.TODO(), rollbackBundles)
if err != nil {
// Why cancel here and not try to clean up as much as possible?
job.State = model.JobStateCancelled
return ver, errors.Wrapf(err, "failed to notify PD the placement rules")
}
Expand Down Expand Up @@ -1813,6 +1823,22 @@ func (w *worker) onDropTablePartition(d *ddlCtx, t *meta.Meta, job *model.Job) (
return ver, errors.Trace(err)
}
}
if tblInfo.TiFlashReplica != nil {
// Remove the partitions
ids := tblInfo.TiFlashReplica.AvailablePartitionIDs
// Rarely called, so OK to take some time, to make it easy
for _, id := range physicalTableIDs {
for i, avail := range ids {
if id == avail {
tmp := ids[:i]
tmp = append(tmp, ids[i+1:]...)
ids = tmp
break
}
}
}
tblInfo.TiFlashReplica.AvailablePartitionIDs = ids
}
tblInfo.Partition.DroppingDefinitions = nil
// used by ApplyDiff in updateSchemaVersion
job.CtxVars = []interface{}{physicalTableIDs}
Expand Down Expand Up @@ -2373,20 +2399,25 @@ func (w *worker) onReorganizePartition(d *ddlCtx, t *meta.Meta, job *model.Job)
// For available state, the new added partition should wait its replica to
// be finished, otherwise the query to this partition will be blocked.
count := tblInfo.TiFlashReplica.Count
needRetry, err := checkPartitionReplica(count, addingDefinitions, d)
needRetry, err := checkPartitionReplica(count, count, addingDefinitions, d)
if err != nil {
// need to rollback, since we tried to register the new
// partitions before!
return convertAddTablePartitionJob2RollbackJob(d, t, job, err, tblInfo)
}
// Try for 10 rounds (in case of transient TiFlash issues)
if needRetry {
// The new added partition hasn't been replicated.
// Do nothing to the job this time, wait next worker round.
time.Sleep(tiflashCheckTiDBHTTPAPIHalfInterval)
// Set the error here which will lead this job exit when it's retry times beyond the limitation.
return ver, errors.Errorf("[ddl] add partition wait for tiflash replica to complete")
}
if job.ErrorCount < 10 {
// The new added partition hasn't been replicated.
// Do nothing to the job this time, wait next worker round.
time.Sleep(tiflashCheckTiDBHTTPAPIHalfInterval)
// Set the error here which will lead this job exit when it's retry times beyond the limitation.
return ver, errors.Errorf("[ddl] reorganize partition wait for tiflash replica to complete")
}

logutil.Logger(w.logCtx).Error("[ddl] reorganize partition could not find all new regions in TiFlash replicas, skipping syncing to TiFlash!", zap.String("table", tblInfo.Name.O))
return convertAddTablePartitionJob2RollbackJob(d, t, job, err, tblInfo)
}
// When TiFlash Replica is ready, we must move them into `AvailablePartitionIDs`.
// Since onUpdateFlashReplicaStatus cannot see the partitions yet (not public)
for _, d := range addingDefinitions {
Expand Down Expand Up @@ -2785,6 +2816,7 @@ func (w *worker) reorgPartitionDataAndIndex(t table.Table, reorgInfo *reorgInfo)
// First run, have not yet started backfilling index data
// Restart with the first new partition.
// TODO: handle remove partitioning
// TODO: Check if there is a better way to restart?
reorgInfo.PhysicalTableID = firstNewPartitionID
} else {
// The job was interrupted and has been restarted,
Expand Down
32 changes: 24 additions & 8 deletions ddl/reorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"encoding/hex"
"fmt"
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -300,6 +301,11 @@ func updateBackfillProgress(w *worker, reorgInfo *reorgInfo, tblInfo *model.Tabl
if progress > 1 {
progress = 1
}
// TODO: change back to Debug
logutil.BgLogger().Info("[ddl] update progress",
zap.Float64("progress", progress),
zap.Int64("addedRowCount", addedRowCount),
zap.Int64("totalCount", totalCount))
}
switch reorgInfo.Type {
case model.ActionAddIndex, model.ActionAddPrimaryKey:
Expand Down Expand Up @@ -330,9 +336,20 @@ func getTableTotalCount(w *worker, tblInfo *model.TableInfo) int64 {
if !ok {
return statistics.PseudoRowCount
}
// TODO: if Reorganize Partition, only select number of rows from the selected partitions!
sql := "select table_rows from information_schema.tables where tidb_table_id=%?;"
rows, _, err := executor.ExecRestrictedSQL(w.ctx, nil, sql, tblInfo.ID)
var rows []chunk.Row
if tblInfo.Partition != nil && len(tblInfo.Partition.DroppingDefinitions) > 0 {
// if Reorganize Partition, only select number of rows from the selected partitions!
defs := tblInfo.Partition.DroppingDefinitions
partIDs := make([]string, 0, len(defs))
for _, def := range defs {
partIDs = append(partIDs, strconv.FormatInt(def.ID, 10))
}
sql := "select sum(table_rows) from information_schema.partitions where tidb_partition_id in (%?);"
rows, _, err = executor.ExecRestrictedSQL(w.ctx, nil, sql, strings.Join(partIDs, ","))
} else {
sql := "select table_rows from information_schema.tables where tidb_table_id=%?;"
rows, _, err = executor.ExecRestrictedSQL(w.ctx, nil, sql, tblInfo.ID)
}
if err != nil {
return statistics.PseudoRowCount
}
Expand Down Expand Up @@ -553,12 +570,12 @@ func getTableRange(ctx *JobContext, d *ddlCtx, tbl table.PhysicalTable, snapshot
endHandleKey = tablecodec.EncodeRecordKey(tbl.RecordPrefix(), maxHandle)
}
if isEmptyTable || endHandleKey.Cmp(startHandleKey) < 0 {
logutil.BgLogger().Info("[ddl] get noop table range",
logutil.BgLogger().Info("[ddl] get table range, endHandle < startHandle",
zap.String("table", fmt.Sprintf("%v", tbl.Meta())),
zap.Int64("table/partition ID", tbl.GetPhysicalID()),
zap.String("start key", hex.EncodeToString(startHandleKey)),
zap.String("end key", hex.EncodeToString(endHandleKey)),
zap.Bool("is empty table", isEmptyTable))
zap.Bool("isEmptyTable", isEmptyTable),
zap.String("endHandle", hex.EncodeToString(endHandleKey)),
zap.String("startHandle", hex.EncodeToString(startHandleKey)))
endHandleKey = startHandleKey
}
return
Expand Down Expand Up @@ -694,7 +711,6 @@ func getReorgInfoFromPartitions(ctx *JobContext, d *ddlCtx, rh *reorgHandler, jo
}
pid = partitionIDs[0]
physTbl := tbl.GetPartition(pid)

start, end, err = getTableRange(ctx, d, physTbl, ver.Ver, job.Priority)
if err != nil {
return nil, errors.Trace(err)
Expand Down
3 changes: 2 additions & 1 deletion ddl/sanity_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ func expectedDeleteRangeCnt(ctx delRangeCntCtx, job *model.Job) (int, error) {
return 0, errors.Trace(err)
}
return mathutil.Max(len(physicalTableIDs), 1), nil
case model.ActionDropTablePartition, model.ActionTruncateTablePartition:
case model.ActionDropTablePartition, model.ActionTruncateTablePartition,
model.ActionReorganizePartition:
var physicalTableIDs []int64
if err := job.DecodeArgs(&physicalTableIDs); err != nil {
return 0, errors.Trace(err)
Expand Down
1 change: 1 addition & 0 deletions ddl/tiflashtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ go_test(
"//store/mockstore/unistore",
"//table",
"//testkit",
"//testkit/external",
"//testkit/testsetup",
"//util",
"//util/logutil",
Expand Down
Loading