Skip to content

Commit 3d176c5

Browse files
committed
Merge branch 'master' of github.com:Altinity/clickhouse-backup into improve_restore_table_mapping
2 parents 27758a0 + 722de68 commit 3d176c5

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
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",

pkg/server/server.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ func (api *APIServer) httpCreateRemoteHandler(w http.ResponseWriter, r *http.Req
11751175
return
11761176
}
11771177

1178-
commandId, _ := status.Current.Start(fullCommand)
1178+
commandId, _ := status.Current.StartWithOperationId(fullCommand, operationId.String())
11791179
go func() {
11801180
err, _ := api.metrics.ExecuteWithMetrics("create_remote", 0, func() error {
11811181
b := backup.NewBackuper(cfg)
@@ -1485,8 +1485,8 @@ func (api *APIServer) httpUploadHandler(w http.ResponseWriter, r *http.Request)
14851485
return
14861486
}
14871487

1488+
commandId, _ := status.Current.StartWithOperationId(fullCommand, operationId.String())
14881489
go func() {
1489-
commandId, _ := status.Current.StartWithOperationId(fullCommand, operationId.String())
14901490
err, _ := api.metrics.ExecuteWithMetrics("upload", 0, func() error {
14911491
b := backup.NewBackuper(cfg)
14921492
return b.Upload(name, deleteSource, diffFrom, diffFromRemote, tablePattern, partitionsToBackup, skipProjections, schemaOnly, rbacOnly, configsOnly, namedCollectionsOnly, resume, api.cliApp.Version, commandId)
@@ -1925,7 +1925,7 @@ func (api *APIServer) httpRestoreRemoteHandler(w http.ResponseWriter, r *http.Re
19251925
return
19261926
}
19271927

1928-
commandId, _ := status.Current.Start(fullCommand)
1928+
commandId, _ := status.Current.StartWithOperationId(fullCommand, operationId.String())
19291929
go func() {
19301930
err, _ := api.metrics.ExecuteWithMetrics("restore_remote", 0, func() error {
19311931
b := backup.NewBackuper(cfg)
@@ -2030,8 +2030,8 @@ func (api *APIServer) httpDownloadHandler(w http.ResponseWriter, r *http.Request
20302030
return
20312031
}
20322032

2033+
commandId, _ := status.Current.StartWithOperationId(fullCommand, operationId.String())
20332034
go func() {
2034-
commandId, _ := status.Current.StartWithOperationId(fullCommand, operationId.String())
20352035
err, _ := api.metrics.ExecuteWithMetrics("download", 0, func() error {
20362036
b := backup.NewBackuper(cfg)
20372037
return b.Download(name, tablePattern, partitionsToBackup, schemaOnly, rbacOnly, configsOnly, namedCollectionsOnly, resume, hardlinkExistsFiles, api.cliApp.Version, commandId)

0 commit comments

Comments
 (0)