Skip to content

Commit a35320b

Browse files
committed
backup: always write slim manifest
Previously, backups would write the slim manifest if the a default true cluster setting was true. This patch removes this cluster setting, so backups will always write the slim manifest. This work is part of an effort to remove deprecated backup manifest versions. Since this patch will take effect on 25.4 clusters, backup _reads_ on 26.2 clusters can exclusively use the slim manifest without any failback logic to the deprecated fat manifest. Since there still exists logic to read the deprecated manifest exclusively (e.g. SHOW BACKUPS), we cannot remove the deprecated manifest _write_ path until all these read paths have fallback logic to the new slim manifest-- work for an upcoming PR. Informs #139159 Release note: none
1 parent 79c72ae commit a35320b

File tree

7 files changed

+10
-41
lines changed

7 files changed

+10
-41
lines changed

pkg/backup/backup_job.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -427,24 +427,16 @@ func backup(
427427
}
428428
}
429429

430-
// Write a `BACKUP_MANIFEST` file to support backups in mixed-version clusters
431-
// with 22.2 nodes.
432-
//
433-
// TODO(adityamaru): We can stop writing `BACKUP_MANIFEST` in 23.2
434-
// because a mixed-version cluster with 23.1 nodes will read the
435-
// `BACKUP_METADATA` instead.
430+
// TODO(msbutler): version gate writing the old manifest once we can guarantee
431+
// a cluster version that will not read the old manifest.
436432
if err := backupinfo.WriteBackupManifest(ctx, defaultStore, backupbase.BackupManifestName,
437433
encryption, &kmsEnv, backupManifest); err != nil {
438434
return roachpb.RowCount{}, 0, err
439435
}
440436

441-
// Write a `BACKUP_METADATA` file along with SSTs for all the alloc heavy
442-
// fields elided from the `BACKUP_MANIFEST`.
443-
if backupinfo.WriteMetadataWithExternalSSTsEnabled.Get(&settings.SV) {
444-
if err := backupinfo.WriteMetadataWithExternalSSTs(ctx, defaultStore, encryption,
445-
&kmsEnv, backupManifest); err != nil {
446-
return roachpb.RowCount{}, 0, err
447-
}
437+
if err := backupinfo.WriteMetadataWithExternalSSTs(ctx, defaultStore, encryption,
438+
&kmsEnv, backupManifest); err != nil {
439+
return roachpb.RowCount{}, 0, err
448440
}
449441

450442
statsTable := getTableStatsForBackup(ctx, execCtx.ExecCfg().InternalDB.Executor(), backupManifest.Descriptors)

pkg/backup/backup_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8456,7 +8456,6 @@ func TestIncorrectAccessOfFilesInBackupMetadata(t *testing.T) {
84568456

84578457
_, sqlDB, rawDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 1, InitManualReplication)
84588458
defer cleanupFn()
8459-
sqlDB.Exec(t, `SET CLUSTER SETTING backup.write_metadata_with_external_ssts.enabled=true`)
84608459
sqlDB.Exec(t, `CREATE DATABASE r1`)
84618460
sqlDB.Exec(t, `CREATE TABLE r1.foo ( id INT PRIMARY KEY)`)
84628461
sqlDB.Exec(t, `INSERT INTO r1.foo VALUES (1)`)
@@ -8502,7 +8501,6 @@ func TestRestoringAcrossVersions(t *testing.T) {
85028501
tc, sqlDB, rawDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 1, InitManualReplication)
85038502
defer cleanupFn()
85048503

8505-
sqlDB.Exec(t, `SET CLUSTER SETTING backup.write_metadata_with_external_ssts.enabled=true`)
85068504
sqlDB.Exec(t, `CREATE DATABASE r1`)
85078505

85088506
sqlDB.Exec(t, `BACKUP DATABASE r1 INTO 'nodelocal://1/cross_version'`)
@@ -8615,7 +8613,6 @@ func TestManifestBitFlip(t *testing.T) {
86158613
defer leaktest.AfterTest(t)()
86168614
defer log.Scope(t).Close(t)
86178615
_, sqlDB, rawDir, cleanupFn := backupRestoreTestSetup(t, singleNode, 1, InitManualReplication)
8618-
sqlDB.Exec(t, `SET CLUSTER SETTING backup.write_metadata_with_external_ssts.enabled=true`)
86198616
defer cleanupFn()
86208617
sqlDB.Exec(t, `CREATE DATABASE r1; CREATE DATABASE r2; CREATE DATABASE r3;`)
86218618
const checksumError = "checksum mismatch"

pkg/backup/backupbase/constants.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ const (
3838
// BackupManifestName is the file name used for serialized BackupManifest
3939
// protos.
4040
//
41-
// TODO(adityamaru): Remove in 23.2 since at that point all nodes will be
42-
// writing a SlimBackupManifest instead.
41+
// TODO(msbutler): Remove 26.3 when we're guaranteed that no backup wrote
42+
// exclusively the backup_manifest, and not the slim manifest.
4343
BackupManifestName = "BACKUP_MANIFEST"
4444

4545
// BackupMetadataName is the file name used for serialized BackupManifest

pkg/backup/backupinfo/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ go_library(
2424
"//pkg/kv/kvpb",
2525
"//pkg/roachpb",
2626
"//pkg/security/username",
27-
"//pkg/settings",
2827
"//pkg/sql",
2928
"//pkg/sql/catalog",
3029
"//pkg/sql/catalog/dbdesc",
@@ -44,7 +43,6 @@ go_library(
4443
"//pkg/util/hlc",
4544
"//pkg/util/ioctx",
4645
"//pkg/util/log",
47-
"//pkg/util/metamorphic",
4846
"//pkg/util/mon",
4947
"//pkg/util/protoutil",
5048
"//pkg/util/syncutil",

pkg/backup/backupinfo/manifest_handling.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
3030
"github.com/cockroachdb/cockroach/pkg/roachpb"
3131
"github.com/cockroachdb/cockroach/pkg/security/username"
32-
"github.com/cockroachdb/cockroach/pkg/settings"
3332
"github.com/cockroachdb/cockroach/pkg/sql"
3433
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
3534
"github.com/cockroachdb/cockroach/pkg/sql/catalog/dbdesc"
@@ -48,7 +47,6 @@ import (
4847
"github.com/cockroachdb/cockroach/pkg/util/hlc"
4948
"github.com/cockroachdb/cockroach/pkg/util/ioctx"
5049
"github.com/cockroachdb/cockroach/pkg/util/log"
51-
"github.com/cockroachdb/cockroach/pkg/util/metamorphic"
5250
"github.com/cockroachdb/cockroach/pkg/util/mon"
5351
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
5452
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
@@ -86,17 +84,6 @@ const (
8684
BackupProgressDirectory = "progress"
8785
)
8886

89-
// WriteMetadataWithExternalSSTsEnabled controls if we write a `BACKUP_METADATA`
90-
// file along with external SSTs containing lists of `BackupManifest_Files` and
91-
// descriptors. This new format of metadata is written in addition to the
92-
// `BACKUP_MANIFEST` file, and is expected to be its replacement in the future.
93-
var WriteMetadataWithExternalSSTsEnabled = settings.RegisterBoolSetting(
94-
settings.ApplicationLevel,
95-
"backup.write_metadata_with_external_ssts.enabled",
96-
"write BACKUP metadata along with supporting SST files",
97-
metamorphic.ConstantWithTestBool("backup.write_metadata_with_external_ssts.enabled", true),
98-
)
99-
10087
// IsGZipped detects whether the given bytes represent GZipped data. This check
10188
// is used rather than a standard implementation such as http.DetectContentType
10289
// since some zipped data may be mis-identified by that method. We've seen

pkg/backup/compaction_job.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -797,11 +797,9 @@ func concludeBackupCompaction(
797797
details.EncryptionOptions, kmsEnv, backupManifest); err != nil {
798798
return err
799799
}
800-
if backupinfo.WriteMetadataWithExternalSSTsEnabled.Get(&execCtx.ExecCfg().Settings.SV) {
801-
if err := backupinfo.WriteMetadataWithExternalSSTs(ctx, store, details.EncryptionOptions,
802-
kmsEnv, backupManifest); err != nil {
803-
return err
804-
}
800+
if err := backupinfo.WriteMetadataWithExternalSSTs(ctx, store, details.EncryptionOptions,
801+
kmsEnv, backupManifest); err != nil {
802+
return err
805803
}
806804

807805
statsTable := getTableStatsForBackup(ctx, execCtx.ExecCfg().InternalDB.Executor(), backupManifest.Descriptors)

pkg/backup/compaction_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"testing"
1717
"time"
1818

19-
"github.com/cockroachdb/cockroach/pkg/backup/backupinfo"
2019
"github.com/cockroachdb/cockroach/pkg/backup/backuppb"
2120
"github.com/cockroachdb/cockroach/pkg/base"
2221
"github.com/cockroachdb/cockroach/pkg/build"
@@ -47,11 +46,9 @@ func TestBackupCompaction(t *testing.T) {
4746
defer leaktest.AfterTest(t)()
4847
defer log.Scope(t).Close(t)
4948

50-
ctx := context.Background()
5149
tempDir, tempDirCleanup := testutils.TempDir(t)
5250
defer tempDirCleanup()
5351
st := cluster.MakeTestingClusterSettings()
54-
backupinfo.WriteMetadataWithExternalSSTsEnabled.Override(ctx, &st.SV, true)
5552
_, db, cleanupDB := backupRestoreTestSetupEmpty(
5653
t, singleNode, tempDir, InitManualReplication, base.TestClusterArgs{
5754
ServerArgs: base.TestServerArgs{

0 commit comments

Comments
 (0)