Skip to content

Commit 726b6c8

Browse files
authored
importinto: disable switching to 'import mode' when global sort (#60363) (#62027)
close #60361
1 parent d437441 commit 726b6c8

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

pkg/executor/importer/import.go

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,30 @@ const (
8181
// 0 means no limit
8282
unlimitedWriteSpeed = config.ByteSize(0)
8383

84-
characterSetOption = "character_set"
85-
fieldsTerminatedByOption = "fields_terminated_by"
86-
fieldsEnclosedByOption = "fields_enclosed_by"
87-
fieldsEscapedByOption = "fields_escaped_by"
88-
fieldsDefinedNullByOption = "fields_defined_null_by"
89-
linesTerminatedByOption = "lines_terminated_by"
90-
skipRowsOption = "skip_rows"
91-
splitFileOption = "split_file"
92-
diskQuotaOption = "disk_quota"
93-
threadOption = "thread"
94-
maxWriteSpeedOption = "max_write_speed"
95-
checksumTableOption = "checksum_table"
96-
recordErrorsOption = "record_errors"
97-
detachedOption = "detached"
84+
characterSetOption = "character_set"
85+
fieldsTerminatedByOption = "fields_terminated_by"
86+
fieldsEnclosedByOption = "fields_enclosed_by"
87+
fieldsEscapedByOption = "fields_escaped_by"
88+
fieldsDefinedNullByOption = "fields_defined_null_by"
89+
linesTerminatedByOption = "lines_terminated_by"
90+
skipRowsOption = "skip_rows"
91+
splitFileOption = "split_file"
92+
diskQuotaOption = "disk_quota"
93+
threadOption = "thread"
94+
maxWriteSpeedOption = "max_write_speed"
95+
checksumTableOption = "checksum_table"
96+
recordErrorsOption = "record_errors"
97+
detachedOption = "detached"
98+
// if 'import mode' enabled, TiKV will:
99+
// - set level0_stop_writes_trigger = max(old, 1 << 30)
100+
// - set level0_slowdown_writes_trigger = max(old, 1 << 30)
101+
// - set soft_pending_compaction_bytes_limit = 0,
102+
// - set hard_pending_compaction_bytes_limit = 0,
103+
// - will not trigger flow control when SST count in L0 is large
104+
// - will not trigger region split, it might cause some region became
105+
// very large and be a hotspot, might cause latency spike.
106+
//
107+
// default false for local sort, true for global sort.
98108
disableTiKVImportModeOption = "disable_tikv_import_mode"
99109
cloudStorageURIOption = "cloud_storage_uri"
100110
disablePrecheckOption = "disable_precheck"
@@ -782,6 +792,9 @@ func (p *Plan) adjustOptions(targetNodeCPUCnt int) {
782792
zap.Int("before", p.ThreadCnt), zap.Int("after", limit))
783793
p.ThreadCnt = limit
784794
}
795+
if p.IsGlobalSort() {
796+
p.DisableTiKVImportMode = true
797+
}
785798
}
786799

787800
func (p *Plan) initParameters(plan *plannercore.ImportInto) error {

pkg/executor/importer/import_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,17 @@ func TestAdjustOptions(t *testing.T) {
187187
plan.adjustOptions(16)
188188
require.Equal(t, 16, plan.ThreadCnt)
189189
require.Equal(t, config.ByteSize(10), plan.MaxWriteSpeed) // not adjusted
190+
require.False(t, plan.DisableTiKVImportMode)
190191

191192
plan.ThreadCnt = 100000000
192193
plan.DataSourceType = DataSourceTypeQuery
193194
plan.adjustOptions(16)
194195
require.Equal(t, 32, plan.ThreadCnt)
196+
require.False(t, plan.DisableTiKVImportMode)
197+
198+
plan.CloudStorageURI = "s3://bucket/path"
199+
plan.adjustOptions(16)
200+
require.True(t, plan.DisableTiKVImportMode)
195201
}
196202

197203
func TestAdjustDiskQuota(t *testing.T) {

tests/realtikvtest/importintotest3/from_server_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@ func (s *mockGCSSuite) TestImportFromServer() {
7373
var taskMeta importinto.TaskMeta
7474
require.NoError(s.T(), json.Unmarshal(task.Meta, &taskMeta))
7575
require.Len(s.T(), taskMeta.ChunkMap, 2)
76+
require.False(s.T(), taskMeta.Plan.DisableTiKVImportMode)
7677
}

tests/realtikvtest/importintotest4/global_sort_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func (s *mockGCSSuite) TestGlobalSortBasic() {
9797
taskMeta := importinto.TaskMeta{}
9898
s.NoError(json.Unmarshal(task.Meta, &taskMeta))
9999
urlEqual(s.T(), redactedSortStorageURI, taskMeta.Plan.CloudStorageURI)
100+
require.True(s.T(), taskMeta.Plan.DisableTiKVImportMode)
100101

101102
// merge-sort data kv
102103
s.tk.MustExec("truncate table t")

0 commit comments

Comments
 (0)