-
Notifications
You must be signed in to change notification settings - Fork 283
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
config(dm): add on-duplicate-logical, on-duplicate-physical #7714
Changes from all commits
ad627ce
e07dd6a
7941977
94fbe89
393f7c0
56dbede
0121d7e
34911a8
11a032f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,34 +250,48 @@ const ( | |
LoadModePhysical = "physical" | ||
) | ||
|
||
// DuplicateResolveType defines the duplication resolution when meet duplicate rows. | ||
type DuplicateResolveType string | ||
// LogicalDuplicateResolveType defines the duplication resolution when meet duplicate rows for logical import. | ||
type LogicalDuplicateResolveType string | ||
|
||
const ( | ||
// OnDuplicateReplace represents replace the old row with new data. | ||
OnDuplicateReplace DuplicateResolveType = "replace" | ||
OnDuplicateReplace LogicalDuplicateResolveType = "replace" | ||
// OnDuplicateError represents return an error when meet duplicate row. | ||
OnDuplicateError = "error" | ||
OnDuplicateError LogicalDuplicateResolveType = "error" | ||
// OnDuplicateIgnore represents ignore the new data when meet duplicate row. | ||
OnDuplicateIgnore = "ignore" | ||
OnDuplicateIgnore LogicalDuplicateResolveType = "ignore" | ||
) | ||
|
||
// PhysicalDuplicateResolveType defines the duplication resolution when meet duplicate rows for physical import. | ||
type PhysicalDuplicateResolveType string | ||
|
||
const ( | ||
// OnDuplicateNone represents do nothing when meet duplicate row and the task will continue. | ||
OnDuplicateNone PhysicalDuplicateResolveType = "none" | ||
// OnDuplicateManual represents that task should be paused when meet duplicate row to let user handle it manually. | ||
OnDuplicateManual PhysicalDuplicateResolveType = "manual" | ||
) | ||
|
||
// LoaderConfig represents loader process unit's specific config. | ||
type LoaderConfig struct { | ||
PoolSize int `yaml:"pool-size" toml:"pool-size" json:"pool-size"` | ||
Dir string `yaml:"dir" toml:"dir" json:"dir"` | ||
SQLMode string `yaml:"-" toml:"-" json:"-"` // wrote by dump unit (DM op) or jobmaster (DM in engine) | ||
ImportMode LoadMode `yaml:"import-mode" toml:"import-mode" json:"import-mode"` | ||
OnDuplicate DuplicateResolveType `yaml:"on-duplicate" toml:"on-duplicate" json:"on-duplicate"` | ||
PoolSize int `yaml:"pool-size" toml:"pool-size" json:"pool-size"` | ||
Dir string `yaml:"dir" toml:"dir" json:"dir"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I'll check it with PM later, maybe we need add more fields in future There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And also, lightning will check whether the source-dir and sst-dir are on the same disk (for IO performance sake, I think). I'm wondering if we should check it here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. precheck will be ported in another PR |
||
SQLMode string `yaml:"-" toml:"-" json:"-"` // wrote by dump unit (DM op) or jobmaster (DM in engine) | ||
ImportMode LoadMode `yaml:"import-mode" toml:"import-mode" json:"import-mode"` | ||
// deprecated, use OnDuplicateLogical instead. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have any plan to remove the deprecated configuration? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. after all development is finished |
||
OnDuplicate LogicalDuplicateResolveType `yaml:"on-duplicate" toml:"on-duplicate" json:"on-duplicate"` | ||
OnDuplicateLogical LogicalDuplicateResolveType `yaml:"on-duplicate-logical" toml:"on-duplicate-logical" json:"on-duplicate-logical"` | ||
// TODO: no effects now | ||
OnDuplicatePhysical PhysicalDuplicateResolveType `yaml:"on-duplicate-physical" toml:"on-duplicate-physical" json:"on-duplicate-physical"` | ||
} | ||
|
||
// DefaultLoaderConfig return default loader config for task. | ||
func DefaultLoaderConfig() LoaderConfig { | ||
return LoaderConfig{ | ||
PoolSize: defaultPoolSize, | ||
Dir: defaultDir, | ||
ImportMode: LoadModeLogical, | ||
OnDuplicate: OnDuplicateReplace, | ||
PoolSize: defaultPoolSize, | ||
Dir: defaultDir, | ||
ImportMode: LoadModeLogical, | ||
OnDuplicateLogical: OnDuplicateReplace, | ||
} | ||
} | ||
|
||
|
@@ -308,12 +322,31 @@ func (m *LoaderConfig) adjust() error { | |
return terror.ErrConfigInvalidLoadMode.Generate(m.ImportMode) | ||
} | ||
|
||
if m.OnDuplicate == "" { | ||
m.OnDuplicate = OnDuplicateReplace | ||
if m.PoolSize == 0 { | ||
m.PoolSize = defaultPoolSize | ||
} | ||
|
||
if m.OnDuplicateLogical == "" && m.OnDuplicate != "" { | ||
m.OnDuplicateLogical = m.OnDuplicate | ||
} | ||
m.OnDuplicate = DuplicateResolveType(strings.ToLower(string(m.OnDuplicate))) | ||
if m.OnDuplicate != OnDuplicateReplace && m.OnDuplicate != OnDuplicateError && m.OnDuplicate != OnDuplicateIgnore { | ||
return terror.ErrConfigInvalidDuplicateResolution.Generate(m.OnDuplicate) | ||
if m.OnDuplicateLogical == "" { | ||
m.OnDuplicateLogical = OnDuplicateReplace | ||
} | ||
m.OnDuplicateLogical = LogicalDuplicateResolveType(strings.ToLower(string(m.OnDuplicateLogical))) | ||
switch m.OnDuplicateLogical { | ||
case OnDuplicateReplace, OnDuplicateError, OnDuplicateIgnore: | ||
default: | ||
return terror.ErrConfigInvalidDuplicateResolution.Generate(m.OnDuplicateLogical) | ||
} | ||
|
||
if m.OnDuplicatePhysical == "" { | ||
m.OnDuplicatePhysical = OnDuplicateNone | ||
} | ||
m.OnDuplicatePhysical = PhysicalDuplicateResolveType(strings.ToLower(string(m.OnDuplicatePhysical))) | ||
switch m.OnDuplicatePhysical { | ||
case OnDuplicateNone, OnDuplicateManual: | ||
default: | ||
return terror.ErrConfigInvalidPhysicalDuplicateResolution.Generate(m.OnDuplicatePhysical) | ||
} | ||
|
||
return nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember we have three duplicate resolutions in lightning:
Are there any reasons we don't support it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
record is worse than remove in all respects so we delete it in design
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we don't support "remove" in this version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"manual" is in fact "remove", it will remove the conflict KV first and let user query the recording table to decide to insert which row