Skip to content

Commit d365645

Browse files
committed
backup: add cluster setting for online restore layer limit
Previously, the layer limit for online restore was hardcoded at 3. This commit adds the cluster setting `backup.restore.online_layer_limit`, allowing us to dynamically adjust the layer limit. It is by default set to 10. Epic: None Release note: None
1 parent 6e53270 commit d365645

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

pkg/backup/restore_online.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/cockroachdb/cockroach/pkg/security/username"
2424
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
2525
"github.com/cockroachdb/cockroach/pkg/settings"
26+
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
2627
"github.com/cockroachdb/cockroach/pkg/sql"
2728
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
2829
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descs"
@@ -51,6 +52,15 @@ var onlineRestoreLinkWorkers = settings.RegisterByteSizeSetting(
5152
settings.PositiveInt,
5253
)
5354

55+
var onlineRestoreLayerLimit = settings.RegisterIntSetting(
56+
settings.ApplicationLevel,
57+
"backup.restore.online_layer_limit",
58+
"maximum number of layers to restore in an online restore operation",
59+
10,
60+
settings.PositiveInt,
61+
settings.WithVisibility(settings.Reserved),
62+
)
63+
5464
// splitAndScatter runs through all entries produced by genSpans splitting and
5565
// scattering the key-space designated by the passed rewriter such that if all
5666
// files in the entries in those spans were ingested the amount ingested between
@@ -411,7 +421,9 @@ func sendRemoteAddSSTable(
411421
// checkManifestsForOnlineCompat returns an error if the set of
412422
// manifests appear to be from a backup that we cannot currently
413423
// support for online restore.
414-
func checkManifestsForOnlineCompat(ctx context.Context, manifests []backuppb.BackupManifest) error {
424+
func checkManifestsForOnlineCompat(
425+
ctx context.Context, settings *cluster.Settings, manifests []backuppb.BackupManifest,
426+
) error {
415427
if len(manifests) < 1 {
416428
return errors.AssertionFailedf("expected at least 1 backup manifest")
417429
}
@@ -421,7 +433,7 @@ func checkManifestsForOnlineCompat(ctx context.Context, manifests []backuppb.Bac
421433
}
422434

423435
// TODO(online-restore): Remove once we support layer ordering and have tested some reasonable number of layers.
424-
const layerLimit = 3
436+
layerLimit := int(onlineRestoreLayerLimit.Get(&settings.SV))
425437
if len(manifests) > layerLimit {
426438
return pgerror.Newf(pgcode.FeatureNotSupported, "experimental online restore: too many incremental layers %d (from backup) > %d (limit)", len(manifests), layerLimit)
427439
}

pkg/backup/restore_planning.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,7 @@ func doRestorePlan(
18141814
}
18151815

18161816
if restoreStmt.Options.OnlineImpl() {
1817-
if err := checkManifestsForOnlineCompat(ctx, mainBackupManifests); err != nil {
1817+
if err := checkManifestsForOnlineCompat(ctx, p.ExecCfg().Settings, mainBackupManifests); err != nil {
18181818
return err
18191819
}
18201820
}

0 commit comments

Comments
 (0)