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 @@

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 @@

// PreCheckUsage implements DiskRoot interface.
func (d *diskRootImpl) PreCheckUsage() error {
err := os.MkdirAll(d.path, 0700)
if err != nil {
return dbterror.ErrIngestFailed.FastGenByArgs(err.Error())
}

Check warning on line 122 in ddl/ingest/disk_root.go

View check run for this annotation

Codecov / codecov/patch

ddl/ingest/disk_root.go#L119-L122

Added lines #L119 - L122 were not covered by tests
sz, err := lcom.GetStorageSize(d.path)
if err != nil {
return errors.Trace(err)
return dbterror.ErrIngestFailed.FastGenByArgs(err.Error())

Check warning on line 125 in ddl/ingest/disk_root.go

View check run for this annotation

Codecov / codecov/patch

ddl/ingest/disk_root.go#L125

Added line #L125 was not covered by tests
}
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)

Check warning on line 130 in ddl/ingest/disk_root.go

View check run for this annotation

Codecov / codecov/patch

ddl/ingest/disk_root.go#L129-L130

Added lines #L129 - L130 were not covered by tests
}
return nil
}
Expand Down