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

[WIP] add some logs for debuging #59258

Open
wants to merge 1 commit into
base: release-7.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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: 10 additions & 1 deletion br/pkg/lightning/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ func NewBackend(
}

if shouldCreate {
log.FromContext(ctx).Warn("[issue58437] NewBackend Mkdir", zap.String("config.LocalStoreDir", config.LocalStoreDir))
err = os.Mkdir(config.LocalStoreDir, 0o700)
if err != nil {
return nil, common.ErrInvalidSortedKVDir.Wrap(err).GenWithStackByArgs(config.LocalStoreDir)
Expand Down Expand Up @@ -848,7 +849,9 @@ func (local *Backend) Close() {
// If checkpoint is disabled, or we don't detect any duplicate, then this duplicate
// db dir will be useless, so we clean up this dir.
if allIsWell && (!local.CheckpointEnabled || !hasDuplicates) {
if err := os.RemoveAll(filepath.Join(local.LocalStoreDir, duplicateDBName)); err != nil {
p := filepath.Join(local.LocalStoreDir, duplicateDBName)
local.logger.Warn("[issue58437] Close RemoveAll", zap.String("path", p))
if err := os.RemoveAll(p); err != nil {
local.logger.Warn("remove duplicate db file failed", zap.Error(err))
}
}
Expand All @@ -858,6 +861,7 @@ func (local *Backend) Close() {
// if checkpoint is disable or we finish load all data successfully, then files in this
// dir will be useless, so we clean up this dir and all files in it.
if !local.CheckpointEnabled || common.IsEmptyDir(local.LocalStoreDir) {
local.logger.Warn("[issue58437] Close RemoveAll", zap.String("local.LocalStoreDir", local.LocalStoreDir))
err := os.RemoveAll(local.LocalStoreDir)
if err != nil {
local.logger.Warn("remove local db file failed", zap.Error(err))
Expand Down Expand Up @@ -950,11 +954,13 @@ func (local *Backend) OpenEngine(ctx context.Context, cfg *backend.EngineConfig,

sstDir := engineSSTDir(local.LocalStoreDir, engineUUID)
if !cfg.KeepSortDir {
log.FromContext(ctx).Warn("[issue58437] OpenEngine RemoveAll", zap.String("sstDir", sstDir))
if err := os.RemoveAll(sstDir); err != nil {
return errors.Trace(err)
}
}
if !common.IsDirExists(sstDir) {
log.FromContext(ctx).Warn("[issue58437] OpenEngine Mkdir", zap.String("sstDir", sstDir))
if err := os.Mkdir(sstDir, 0o750); err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -1821,6 +1827,7 @@ func (local *Backend) ResetEngine(ctx context.Context, engineUUID uuid.UUID) err
if err := localEngine.Close(); err != nil {
return err
}
log.FromContext(ctx).Warn("[issue58437] ResetEngine Cleanup", zap.String("local.LocalStoreDir", local.LocalStoreDir))
if err := localEngine.Cleanup(local.LocalStoreDir); err != nil {
return err
}
Expand All @@ -1829,6 +1836,7 @@ func (local *Backend) ResetEngine(ctx context.Context, engineUUID uuid.UUID) err
localEngine.db.Store(db)
localEngine.engineMeta = engineMeta{}
if !common.IsDirExists(localEngine.sstDir) {
log.FromContext(ctx).Warn("[issue58437] ResetEngine Mkdir", zap.String("sstDir", localEngine.sstDir))
if err := os.Mkdir(localEngine.sstDir, 0o750); err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -1867,6 +1875,7 @@ func (local *Backend) CleanupEngine(ctx context.Context, engineUUID uuid.UUID) e
if err != nil {
return err
}
log.FromContext(ctx).Warn("[issue58437] CleanupEngine", zap.Stringer("uuid", engineUUID))
err = localEngine.Cleanup(local.LocalStoreDir)
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion pkg/ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ func loadCloudStorageURI(w *worker, job *model.Job) {
// there maybe some stale files in the sort path if TiDB is killed during the backfill process.
func cleanupSortPath(ctx context.Context, currentJobID int64) error {
sortPath := ingest.ConfigSortPath()
logutil.BgLogger().Warn("[issue58437] cleanupSortPath()", zap.Int64("currentJobID", currentJobID))
err := os.MkdirAll(sortPath, 0700)
if err != nil {
return errors.Trace(err)
Expand All @@ -853,7 +854,7 @@ func cleanupSortPath(ctx context.Context, currentJobID int64) error {
}
// Remove all the temp data of the previous done jobs.
if jobID < currentJobID {
logutil.Logger(ctx).Info("remove stale temp index data",
logutil.Logger(ctx).Info("[issue58437] remove stale temp index data",
zap.Int64("jobID", jobID), zap.Int64("currentJobID", currentJobID))
err := os.RemoveAll(filepath.Join(sortPath, entry.Name()))
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/ddl/ingest/disk_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func (d *diskRootImpl) PreCheckUsage() error {
failpoint.Inject("mockIngestCheckEnvFailed", func(_ failpoint.Value) {
failpoint.Return(dbterror.ErrIngestCheckEnvFailed.FastGenByArgs("mock error"))
})
logutil.BgLogger().Warn("[issue58437] diskRootImpl PreCheckUsage()")
err := os.MkdirAll(d.path, 0700)
if err != nil {
return dbterror.ErrIngestCheckEnvFailed.FastGenByArgs(err.Error())
Expand Down
1 change: 1 addition & 0 deletions pkg/ddl/ingest/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func genLightningDataDir() (string, error) {
return "", err
}
}
logutil.BgLogger().Warn("[issue58437] genLightningDataDir()")
err := os.MkdirAll(sortPath, 0o700)
if err != nil {
logutil.BgLogger().Error(LitErrCreateDirFail,
Expand Down