diff --git a/pkg/storage/engine_test.go b/pkg/storage/engine_test.go index 1b418a58067e..199a3f2e3670 100644 --- a/pkg/storage/engine_test.go +++ b/pkg/storage/engine_test.go @@ -1004,15 +1004,26 @@ func TestCreateCheckpoint(t *testing.T) { assert.NoError(t, err) defer db.Close() - dir = filepath.Join(dir, "checkpoint") + checkpointDir := filepath.Join(dir, "checkpoint") assert.NoError(t, err) - assert.NoError(t, db.CreateCheckpoint(dir, nil)) - assert.DirExists(t, dir) - m, err := filepath.Glob(dir + "/*") + assert.NoError(t, db.CreateCheckpoint(checkpointDir, nil)) + assert.DirExists(t, checkpointDir) + m, err := filepath.Glob(checkpointDir + "/*") assert.NoError(t, err) assert.True(t, len(m) > 0) - if err := db.CreateCheckpoint(dir, nil); !testutils.IsError(err, "exists") { + + // Verify that we can open the checkpoint. + db2, err := Open( + context.Background(), + Filesystem(checkpointDir), + cluster.MakeTestingClusterSettings(), + MustExist) + require.NoError(t, err) + db2.Close() + + // Verify that creating another checkpoint in the same directory fails. + if err := db.CreateCheckpoint(checkpointDir, nil); !testutils.IsError(err, "exists") { t.Fatal(err) } } diff --git a/pkg/storage/pebble.go b/pkg/storage/pebble.go index d6ae114bebcb..0630276ad323 100644 --- a/pkg/storage/pebble.go +++ b/pkg/storage/pebble.go @@ -1950,11 +1950,21 @@ func (p *Pebble) CreateCheckpoint(dir string, spans []roachpb.Span) error { return err } + // Write out the min version file. + if err := writeMinVersionFile(p.unencryptedFS, dir, p.MinVersion()); err != nil { + return errors.Wrapf(err, "writing min version file for checkpoint") + } + // TODO(#90543, cockroachdb/pebble#2285): move spans info to Pebble manifest. if len(spans) > 0 { - return fs.SafeWriteToFile(p.fs, dir, p.fs.PathJoin(dir, "checkpoint.txt"), - checkpointSpansNote(spans)) + if err := fs.SafeWriteToFile( + p.fs, dir, p.fs.PathJoin(dir, "checkpoint.txt"), + checkpointSpansNote(spans), + ); err != nil { + return err + } } + return nil }