@@ -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 }
0 commit comments