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

ddl: create temp dir automatically for adding index #45457

Merged
merged 5 commits into from
Jul 20, 2023
Merged
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions ddl/ingest/disk_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ package ingest

import (
"fmt"
"os"
"sync"
"sync/atomic"

"github.com/pingcap/errors"
lcom "github.com/pingcap/tidb/br/pkg/lightning/common"
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/util/dbterror"
"github.com/pingcap/tidb/util/logutil"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -114,13 +116,18 @@ func (d *diskRootImpl) usageInfo() string {

// PreCheckUsage implements DiskRoot interface.
func (d *diskRootImpl) PreCheckUsage() error {
err := os.MkdirAll(d.path, 0700)
if err != nil {
return dbterror.ErrIngestFailed.FastGenByArgs(err.Error())
}
sz, err := lcom.GetStorageSize(d.path)
if err != nil {
return errors.Trace(err)
return dbterror.ErrIngestFailed.FastGenByArgs(err.Error())
}
if RiskOfDiskFull(sz.Available, sz.Capacity) {
sortPath := ConfigSortPath()
return errors.Errorf("sort path: %s, %s, please clean up the disk and retry", sortPath, d.UsageInfo())
msg := fmt.Sprintf("sort path: %s, %s, please clean up the disk and retry", sortPath, d.UsageInfo())
return dbterror.ErrIngestFailed.FastGenByArgs(msg)
}
return nil
}
Expand Down