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

Lightning: Update Parameter Name from tikv-importer.incremental-import to tikv-importer.parallel-import #45539

Merged
merged 5 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
23 changes: 16 additions & 7 deletions br/pkg/lightning/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1050,9 +1050,11 @@ type TikvImporter struct {
DiskQuota ByteSize `toml:"disk-quota" json:"disk-quota"`
RangeConcurrency int `toml:"range-concurrency" json:"range-concurrency"`
DuplicateResolution DuplicateResolutionAlgorithm `toml:"duplicate-resolution" json:"duplicate-resolution"`
IncrementalImport bool `toml:"incremental-import" json:"incremental-import"`
KeyspaceName string `toml:"keyspace-name" json:"keyspace-name"`
AddIndexBySQL bool `toml:"add-index-by-sql" json:"add-index-by-sql"`
// deprecated, use ParallelImport instead.
IncrementalImport bool `toml:"incremental-import" json:"incremental-import"`
ParallelImport bool `toml:"parallel-import" json:"parallel-import"`
KeyspaceName string `toml:"keyspace-name" json:"keyspace-name"`
AddIndexBySQL bool `toml:"add-index-by-sql" json:"add-index-by-sql"`

EngineMemCacheSize ByteSize `toml:"engine-mem-cache-size" json:"engine-mem-cache-size"`
LocalWriterMemCacheSize ByteSize `toml:"local-writer-mem-cache-size" json:"local-writer-mem-cache-size"`
Expand All @@ -1066,6 +1068,13 @@ func (t *TikvImporter) adjust() error {
return common.ErrInvalidConfig.GenWithStack("tikv-importer.backend must not be empty!")
}
t.Backend = strings.ToLower(t.Backend)
if !t.ParallelImport && t.IncrementalImport {
// need to assign t.IncrementalImport to t.ParallelImport when t.ParallelImport is false and t.IncrementalImport is true
t.ParallelImport = t.IncrementalImport
} else if t.ParallelImport && !t.IncrementalImport {
// need to assign t.ParallelImport to t.IncrementalImport when t.IncrementalImport is false and t.ParallelImport is true, to keep compatibility
t.IncrementalImport = t.ParallelImport
lance6716 marked this conversation as resolved.
Show resolved Hide resolved
}
switch t.Backend {
case BackendTiDB:
t.DuplicateResolution = DupeResAlgNone
Expand All @@ -1090,9 +1099,9 @@ func (t *TikvImporter) adjust() error {
t.LocalWriterMemCacheSize = DefaultLocalWriterMemCacheSize
}

if t.IncrementalImport && t.AddIndexBySQL {
if t.ParallelImport && t.AddIndexBySQL {
return common.ErrInvalidConfig.
GenWithStack("tikv-importer.add-index-using-ddl cannot be used with tikv-importer.incremental-import")
GenWithStack("tikv-importer.add-index-using-ddl cannot be used with tikv-importer.parallel-import")
}

if len(t.SortedKVDir) == 0 {
Expand Down Expand Up @@ -1321,9 +1330,9 @@ func (c *Conflict) adjust(i *TikvImporter, l *Lightning) error {
"unsupported `%s` (%s)", strategyConfigFrom, c.Strategy)
}
if c.Strategy != "" {
if i.IncrementalImport {
if i.ParallelImport {
return common.ErrInvalidConfig.GenWithStack(
"%s cannot be used with tikv-importer.incremental-import",
"%s cannot be used with tikv-importer.parallel-import",
strategyConfigFrom)
}
if i.DuplicateResolution != DupeResAlgNone {
Expand Down
8 changes: 4 additions & 4 deletions br/pkg/lightning/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,12 +982,12 @@ func TestAdjustConflictStrategy(t *testing.T) {

cfg.TikvImporter.Backend = BackendLocal
cfg.Conflict.Strategy = ReplaceOnDup
cfg.TikvImporter.IncrementalImport = true
require.ErrorContains(t, cfg.Adjust(ctx), "conflict.strategy cannot be used with tikv-importer.incremental-import")
cfg.TikvImporter.ParallelImport = true
require.ErrorContains(t, cfg.Adjust(ctx), "conflict.strategy cannot be used with tikv-importer.parallel-import")

cfg.TikvImporter.Backend = BackendLocal
cfg.Conflict.Strategy = ReplaceOnDup
cfg.TikvImporter.IncrementalImport = false
cfg.TikvImporter.ParallelImport = false
cfg.TikvImporter.DuplicateResolution = DupeResAlgRemove
require.ErrorContains(t, cfg.Adjust(ctx), "conflict.strategy cannot be used with tikv-importer.duplicate-resolution")

Expand Down Expand Up @@ -1203,7 +1203,7 @@ func TestAdjustTikvImporter(t *testing.T) {

cfg.TikvImporter.IncrementalImport = true
cfg.TikvImporter.AddIndexBySQL = true
require.ErrorContains(t, cfg.TikvImporter.adjust(), "tikv-importer.add-index-using-ddl cannot be used with tikv-importer.incremental-import")
require.ErrorContains(t, cfg.TikvImporter.adjust(), "tikv-importer.add-index-using-ddl cannot be used with tikv-importer.parallel-import")
}

func TestCreateSeveralConfigsWithDifferentFilters(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/lightning/importer/check_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (rc *Controller) checkCSVHeader(ctx context.Context) error {
}

func (rc *Controller) checkTableEmpty(ctx context.Context) error {
if rc.cfg.TikvImporter.Backend == config.BackendTiDB || rc.cfg.TikvImporter.IncrementalImport {
if rc.cfg.TikvImporter.Backend == config.BackendTiDB || rc.cfg.TikvImporter.ParallelImport {
return nil
}
return rc.doPreCheckOnItem(ctx, precheck.CheckTargetTableEmpty)
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/lightning/importer/check_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func TestCheckTableEmpty(t *testing.T) {

// test incremental mode
rc.cfg.TikvImporter.Backend = config.BackendLocal
rc.cfg.TikvImporter.IncrementalImport = true
rc.cfg.TikvImporter.ParallelImport = true
err = rc.checkTableEmpty(ctx)
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion br/pkg/lightning/importer/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func NewImportControllerWithPauser(
var metaBuilder metaMgrBuilder
isSSTImport := cfg.TikvImporter.Backend == config.BackendLocal
switch {
case isSSTImport && cfg.TikvImporter.IncrementalImport:
case isSSTImport && cfg.TikvImporter.ParallelImport:
metaBuilder = &dbMetaMgrBuilder{
db: db,
taskID: cfg.TaskID,
Expand Down
2 changes: 1 addition & 1 deletion br/tests/lightning_incremental/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[tikv-importer]
incremental-import = true
parallel-import = true