Skip to content

Commit

Permalink
make optional /backup/kill query parameter command and optional a…
Browse files Browse the repository at this point in the history
…rguments for `kill` command handled via `/backup/actions`, if omitted then will kill first command in "In progress" status, fix #808
  • Loading branch information
Slach committed Jan 17, 2024
1 parent e6fa684 commit a33948e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# v2.4.18
BUG FIXES
- remove HeadObject request to calculate source key size in CopyObject, to allow cross region S3 disks backup, fix https://github.com/Altinity/clickhouse-backup/issues/813
- remove HeadObject request to calculate source key size in CopyObject, to allow cross region S3 disks backup, fix [813](https://github.com/Altinity/clickhouse-backup/issues/813)
- make optional `/backup/kill` query parameter `command` and optional arguments for `kill` command handled via `/backup/actions`, if omitted then will kill first command in "In progress" status, fix [808](https://github.com/Altinity/clickhouse-backup/issues/808)

# v2.4.17
BUG FIXES
Expand Down
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ Restart HTTP server, close all current connections, close listen socket, open li
Kill selected command from `GET /backup/actions` command list, kill process should be near immediate, but some go-routines (upload one data part) could continue to run.

- Optional query argument `command` may contain the command name to kill, or if it is omitted then kill the last "in progress" command.
- Optional query argument `command` may contain the command name to kill, or if it is omitted then kill the first "in progress" command.

> **GET /backup/tables**
Expand Down
8 changes: 4 additions & 4 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,10 @@ func (api *APIServer) actionsAsyncCommandsHandler(command string, args []string,
}

func (api *APIServer) actionsKillHandler(row status.ActionRow, args []string, actionsResults []actionsResultsRow) ([]actionsResultsRow, error) {
if len(args) <= 1 {
return actionsResults, errors.New("kill <command> parameter empty")
killCommand := ""
if len(args) > 1 {
killCommand = args[1]
}
killCommand := args[1]
commandId, _ := status.Current.Start(row.Command)
err := status.Current.Cancel(killCommand, fmt.Errorf("canceled from API /backup/actions"))
defer status.Current.Stop(commandId, err)
Expand Down Expand Up @@ -622,7 +622,7 @@ func (api *APIServer) httpKillHandler(w http.ResponseWriter, r *http.Request) {
if exists && len(command) > 0 {
err = status.Current.Cancel(command[0], fmt.Errorf("canceled from API /backup/kill"))
} else {
err = fmt.Errorf("require non empty `command` parameter")
err = status.Current.Cancel("", fmt.Errorf("canceled from API /backup/kill"))
}
if err != nil {
api.sendJSONEachRow(w, http.StatusInternalServerError, struct {
Expand Down

0 comments on commit a33948e

Please sign in to comment.