From 6730919c17f683f195af775acc397ca3919fd8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= <2000michal@wp.pl> Date: Thu, 3 Oct 2024 16:25:22 +0200 Subject: [PATCH] feat(command/restore): allow controlling auto compaction --- .../sctool/partials/sctool_restore.yaml | 5 ++++ .../partials/sctool_restore_update.yaml | 5 ++++ pkg/command/restore/cmd.go | 26 ++++++++++++------- pkg/command/restore/res.yaml | 4 +++ 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/docs/source/sctool/partials/sctool_restore.yaml b/docs/source/sctool/partials/sctool_restore.yaml index 5472c7a2b9..3e87d3d758 100644 --- a/docs/source/sctool/partials/sctool_restore.yaml +++ b/docs/source/sctool/partials/sctool_restore.yaml @@ -7,6 +7,11 @@ description: | a specific follow-up action described by selected type. usage: sctool restore --cluster --location [:]: --snapshot-tag [flags] options: + - name: allow-compaction + default_value: "false" + usage: | + Should auto compactions be running on Scylla nodes during restore. + Disabling auto compactions decreases restore time duration, but increases compaction workload after the restore is done. - name: batch-size default_value: "2" usage: | diff --git a/docs/source/sctool/partials/sctool_restore_update.yaml b/docs/source/sctool/partials/sctool_restore_update.yaml index 34666bf00c..a6b77f36b1 100644 --- a/docs/source/sctool/partials/sctool_restore_update.yaml +++ b/docs/source/sctool/partials/sctool_restore_update.yaml @@ -5,6 +5,11 @@ description: | If there is one restore task the 'restore/task-id' argument is not needed. usage: sctool restore update --cluster [flags] [] options: + - name: allow-compaction + default_value: "false" + usage: | + Should auto compactions be running on Scylla nodes during restore. + Disabling auto compactions decreases restore time duration, but increases compaction workload after the restore is done. - name: batch-size default_value: "2" usage: | diff --git a/pkg/command/restore/cmd.go b/pkg/command/restore/cmd.go index 5863af1e6f..02ec01fa7c 100644 --- a/pkg/command/restore/cmd.go +++ b/pkg/command/restore/cmd.go @@ -23,16 +23,17 @@ type command struct { flag.TaskBase client *managerclient.Client - cluster string - location []string - keyspace []string - snapshotTag string - batchSize int - parallel int - restoreSchema bool - restoreTables bool - dryRun bool - showTables bool + cluster string + location []string + keyspace []string + snapshotTag string + batchSize int + parallel int + allowCompaction bool + restoreSchema bool + restoreTables bool + dryRun bool + showTables bool } func NewCommand(client *managerclient.Client) *cobra.Command { @@ -78,6 +79,7 @@ func (cmd *command) init() { w.Unwrap().StringVarP(&cmd.snapshotTag, "snapshot-tag", "T", "", "") w.Unwrap().IntVar(&cmd.batchSize, "batch-size", 2, "") w.Unwrap().IntVar(&cmd.parallel, "parallel", 1, "") + w.Unwrap().BoolVar(&cmd.allowCompaction, "allow-compaction", false, "") w.Unwrap().BoolVar(&cmd.restoreSchema, "restore-schema", false, "") w.Unwrap().BoolVar(&cmd.restoreTables, "restore-tables", false, "") w.Unwrap().BoolVar(&cmd.dryRun, "dry-run", false, "") @@ -144,6 +146,10 @@ func (cmd *command) run(args []string) error { props["parallel"] = cmd.parallel ok = true } + if cmd.Flag("allow-compaction").Changed { + props["allow_compaction"] = cmd.allowCompaction + ok = true + } if cmd.Flag("restore-schema").Changed { if cmd.Update() { return wrapper("restore-schema") diff --git a/pkg/command/restore/res.yaml b/pkg/command/restore/res.yaml index fb4d9dcd67..2218708489 100644 --- a/pkg/command/restore/res.yaml +++ b/pkg/command/restore/res.yaml @@ -32,6 +32,10 @@ parallel: | The maximum number of Scylla restore jobs that can be run at the same time (on different SSTables). Each node can take part in at most one restore at any given moment. +allow-compaction: | + Should auto compactions be running on Scylla nodes during restore. + Disabling auto compactions decreases restore time duration, but increases compaction workload after the restore is done. + restore-schema: | Specifies restore type (alternative to '--restore-tables' flag). Restore will recreate schema by applying the backed up output of DESCRIBE SCHEMA WITH INTERNALS via CQL.