Repository navigation
importinto: forbid importing into TTL-enabled tables #70427
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ var GetEtcdClient = store.NewEtcdCli | |
|
|
||
| // CheckRequirements checks the requirements for IMPORT INTO. | ||
| // we check the following things here: | ||
| // - target table should not have TTL enabled | ||
| // - when import from file | ||
| // 1. there is no active job on the target table | ||
| // 2. the total file size > 0 | ||
|
|
@@ -60,6 +61,18 @@ func (e *LoadDataController) CheckRequirementsBeforeInitDataFiles(ctx context.Co | |
| } | ||
|
|
||
| func (e *LoadDataController) checkRequirements(ctx context.Context, se sessionctx.Context, checkTotalFileSize bool) error { | ||
| tableInfo := e.Plan.TableInfo | ||
| // Import table mode can prevent TTL from deleting data and causing a checksum | ||
| // mismatch. However, because TTL jobs run asynchronously, a job that races with the | ||
| // switch to import mode may still report a protected-table error. This precheck is | ||
| // also needed on versions that do not support table mode. Therefore, IMPORT INTO | ||
| // forbids importing into a table with TTL enabled. If later testing shows that IMPORT | ||
| // INTO can always switch table mode without an opt-out, TTL can check table mode before | ||
| // starting a job and this precheck can be removed. | ||
| if tableInfo.TTLInfo != nil && tableInfo.TTLInfo.Enable { | ||
|
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. ℹ️ [Info] IMPORT INTO into a TTL-enabled table becomes a hard rejection that DISABLE_PRECHECK cannot overrideAfter upgrade, any existing IMPORT INTO job or automation whose target table has TTL enabled changes from success to a hard error 8173. |
||
| return exeerrors.ErrLoadDataPreCheckFailed.FastGenByArgs("target table has TTL enabled, please disable TTL before IMPORT INTO") | ||
| } | ||
|
|
||
| conn := se.GetSQLExecutor() | ||
| if e.DataSourceType == DataSourceTypeFile { | ||
| cnt, err := GetActiveJobCnt(ctx, conn, e.Plan.DBName, e.Plan.TableInfo.Name.L) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.