Skip to content

Commit

Permalink
importinto: change min thread to 8 for global sort (#52276)
Browse files Browse the repository at this point in the history
ref #49008
  • Loading branch information
D3Hunter committed Apr 2, 2024
1 parent a57ebeb commit d971a6d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pkg/executor/importer/precheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ func (e *LoadDataController) CheckRequirements(ctx context.Context, conn sqlexec
if err := e.checkTotalFileSize(); err != nil {
return err
}
// run global sort with < 16 thread might OOM on merge step
// run global sort with < 8 thread might OOM on ingest step
// TODO: remove this limit after control memory usage.
if e.IsGlobalSort() && e.ThreadCnt < 16 {
return exeerrors.ErrLoadDataPreCheckFailed.FastGenByArgs("global sort requires at least 16 threads")
if e.IsGlobalSort() && e.ThreadCnt < 8 {
return exeerrors.ErrLoadDataPreCheckFailed.FastGenByArgs("global sort requires at least 8 threads")
}
}
if err := e.checkTableEmpty(ctx, conn); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/executor/importer/precheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ func TestCheckRequirements(t *testing.T) {

// make checkTotalFileSize pass
c.TotalFileSize = 1
// global sort with thread count < 16
c.ThreadCnt = 15
// global sort with thread count < 8
c.ThreadCnt = 7
c.CloudStorageURI = "s3://test"
err = c.CheckRequirements(ctx, conn)
require.ErrorIs(t, err, exeerrors.ErrLoadDataPreCheckFailed)
require.ErrorContains(t, err, "global sort requires at least 16 threads")
require.ErrorContains(t, err, "global sort requires at least 8 threads")

// reset fields, make global sort thread check pass
c.ThreadCnt = 1
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestCheckRequirements(t *testing.T) {
require.NoError(t, c.CheckRequirements(ctx, conn))

// with global sort
c.Plan.ThreadCnt = 16
c.Plan.ThreadCnt = 8
c.Plan.CloudStorageURI = ":"
require.ErrorIs(t, c.CheckRequirements(ctx, conn), exeerrors.ErrLoadDataInvalidURI)
c.Plan.CloudStorageURI = "sdsdsdsd://sdsdsdsd"
Expand Down
2 changes: 1 addition & 1 deletion tests/realtikvtest/importintotest4/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestImportInto(t *testing.T) {
}

func (s *mockGCSSuite) SetupSuite() {
testkit.EnableFailPoint(s.T(), "github.com/pingcap/tidb/pkg/util/cpu/mockNumCpu", `return(32)`)
testkit.EnableFailPoint(s.T(), "github.com/pingcap/tidb/pkg/util/cpu/mockNumCpu", `return(16)`)
s.Require().True(*realtikvtest.WithRealTiKV)
testutil.ReduceCheckInterval(s.T())
var err error
Expand Down

0 comments on commit d971a6d

Please sign in to comment.