Skip to content

Commit 902d319

Browse files
committed
fix Download and Upload command proper close resumable state to avoid infinite bolt lock in server mode when upload or download command failed, fix #1304
Signed-off-by: Slach <bloodjazman@gmail.com>
1 parent 7e743f9 commit 902d319

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

pkg/backup/download.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ func (b *Backuper) Download(backupName string, tablePattern string, partitions [
164164
"partitions": partitions,
165165
"schemaOnly": schemaOnly,
166166
})
167+
defer b.resumableState.Close()
167168
}
168169

169170
log.Debug().Str("backup", backupName).Msgf("prepare table METADATA concurrent semaphore with concurrency=%d len(tablesForDownload)=%d", b.cfg.General.DownloadConcurrency, len(tablesForDownload))
@@ -294,10 +295,6 @@ func (b *Backuper) Download(backupName string, tablePattern string, partitions [
294295
}
295296
}
296297

297-
if b.resume {
298-
b.resumableState.Close()
299-
}
300-
301298
//clean partially downloaded requiredBackup
302299
if remoteBackup.RequiredBackup != "" {
303300
if err = b.cleanPartialRequiredBackup(ctx, disks, remoteBackup.BackupName); err != nil {

pkg/backup/upload.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ func (b *Backuper) Upload(backupName string, deleteSource bool, diffFrom, diffFr
135135
"partitions": partitions,
136136
"schemaOnly": schemaOnly,
137137
})
138+
defer b.resumableState.Close()
138139
}
139140

140141
compressedDataSize := int64(0)
@@ -257,9 +258,6 @@ func (b *Backuper) Upload(backupName string, deleteSource bool, diffFrom, diffFr
257258
return errors.Wrapf(err, "can't upload %s", remoteBackupMetaFile)
258259
}
259260
}
260-
if b.resume {
261-
b.resumableState.Close()
262-
}
263261
log.Info().Fields(map[string]interface{}{
264262
"backup": backupName,
265263
"operation": "upload",

0 commit comments

Comments
 (0)