fix: 解决删除数据库过程中导致的锁库

This commit is contained in:
zhengkunwang223
2022-12-27 16:30:25 +08:00
committed by zhengkunwang223
parent aa9f6f0f2b
commit f8409fbfaf
5 changed files with 13 additions and 65 deletions

View File

@@ -44,7 +44,7 @@ type IMysqlService interface {
Recover(db dto.RecoverDB) error
DeleteCheck(id uint) ([]string, error)
Delete(req dto.MysqlDBDelete) error
Delete(ctx context.Context, req dto.MysqlDBDelete) error
LoadStatus() (*dto.MysqlStatus, error)
LoadVariables() (*dto.MysqlVariables, error)
LoadBaseInfo() (*dto.DBBaseInfo, error)
@@ -256,7 +256,7 @@ func (u *MysqlService) DeleteCheck(id uint) ([]string, error) {
return appInUsed, nil
}
func (u *MysqlService) Delete(req dto.MysqlDBDelete) error {
func (u *MysqlService) Delete(ctx context.Context, req dto.MysqlDBDelete) error {
app, err := appInstallRepo.LoadBaseInfo("mysql", "")
if err != nil && !req.ForceDelete {
return err
@@ -288,9 +288,9 @@ func (u *MysqlService) Delete(req dto.MysqlDBDelete) error {
_ = os.RemoveAll(backupDir)
}
}
_ = backupRepo.DeleteRecord(context.Background(), commonRepo.WithByType("database-mysql"), commonRepo.WithByName(app.Name), backupRepo.WithByDetailName(db.Name))
_ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType("database-mysql"), commonRepo.WithByName(app.Name), backupRepo.WithByDetailName(db.Name))
_ = mysqlRepo.Delete(context.Background(), commonRepo.WithByID(db.ID))
_ = mysqlRepo.Delete(ctx, commonRepo.WithByID(db.ID))
return nil
}