Skip to content

Commit 2b10176

Browse files
authored
Merge pull request #154390 from cockroachdb/blathers/backport-release-25.4-154338
release-25.4: roachtest: plumb AOST used in backup fixture fingerprint to restore
2 parents f91163d + 56354fb commit 2b10176

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

pkg/cmd/roachtest/tests/backup_fixtures.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,17 +445,19 @@ func (bd *backupDriver) queryJobStates(
445445
// fingerprintFixture computes fingerprints for the fixture as of the time of
446446
// its last incremental backup. It maps the fully qualified name of each table
447447
// to its fingerprint.
448-
func (bd *backupDriver) fingerprintFixture(ctx context.Context) map[string]string {
448+
func (bd *backupDriver) fingerprintFixture(ctx context.Context, asOfTime string) map[string]string {
449449
conn := bd.c.Conn(ctx, bd.t.L(), 1)
450450
defer conn.Close()
451451
return fingerprintDatabase(
452-
bd.t, conn, bd.sp.fixture.DatabaseName(), bd.getLatestAOST(sqlutils.MakeSQLRunner(conn)),
453-
)
452+
bd.t, conn, bd.sp.fixture.DatabaseName(), asOfTime)
454453
}
455454

456455
// getLatestAOST returns the end time as seen in SHOW BACKUP of the latest
457456
// backup in the fixture.
458-
func (bd *backupDriver) getLatestAOST(sql *sqlutils.SQLRunner) string {
457+
func (bd *backupDriver) getLatestAOST(ctx context.Context) string {
458+
conn := bd.c.Conn(ctx, bd.t.L(), 1)
459+
defer conn.Close()
460+
sql := sqlutils.MakeSQLRunner(conn)
459461
uri := bd.registry.URI(bd.fixture.DataPath)
460462
query := fmt.Sprintf(
461463
`SELECT end_time FROM
@@ -675,8 +677,9 @@ func registerBackupFixtures(r registry.Registry) {
675677
stopWorkload()
676678

677679
if !bf.skipFingerprint {
678-
fingerprint := bd.fingerprintFixture(ctx)
679-
require.NoError(t, handle.SetFingerprint(ctx, fingerprint))
680+
fingerprintTime := bd.getLatestAOST(ctx)
681+
fingerprint := bd.fingerprintFixture(ctx, fingerprintTime)
682+
require.NoError(t, handle.SetFingerprint(ctx, fingerprint, fingerprintTime))
680683
}
681684

682685
require.NoError(t, handle.SetReadyAt(ctx))

pkg/cmd/roachtest/tests/restore.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,11 @@ func (rd *restoreDriver) prepareCluster(ctx context.Context) {
825825

826826
// getAOST gets the AOST to use in the restore cmd.
827827
func (rd *restoreDriver) getAOST(ctx context.Context) {
828+
if rd.fixtureMetadata.FingerprintTime != "" {
829+
rd.aost = rd.fixtureMetadata.FingerprintTime
830+
rd.t.L().Printf("using AOST from fixture metadata: %s", rd.aost)
831+
return
832+
}
828833
if !rd.sp.fullBackupOnly {
829834
rd.aost = ""
830835
return

pkg/roachprod/blobfixture/metadata.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ type FixtureMetadata struct {
4040
// Note: this may not be present if the fixture was too large to be
4141
// fingerprinted.
4242
Fingerprint map[string]string `json:"fingerprint,omitempty"`
43+
44+
// FingerprintTime is the aost used by the fingerprint command.
45+
FingerprintTime string `json:"fingerprint_time,omitempty"`
4346
}
4447

4548
func (f *FixtureMetadata) MarshalJson() ([]byte, error) {

pkg/roachprod/blobfixture/registry.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,14 @@ func (s *ScratchHandle) SetReadyAt(ctx context.Context) error {
333333
}
334334

335335
// SetFingerprint sets the fingerprint for the fixture.
336-
func (s *ScratchHandle) SetFingerprint(ctx context.Context, fingerprint map[string]string) error {
336+
func (s *ScratchHandle) SetFingerprint(
337+
ctx context.Context, fingerprint map[string]string, asOf string,
338+
) error {
337339
s.metadata.Fingerprint = fingerprint
340+
s.metadata.FingerprintTime = asOf
338341
if err := s.registry.upsertMetadata(s.metadata); err != nil {
339342
return err
340343
}
341-
s.logger.Printf("fixture '%s' fingerprint set to '%s'", s.metadata.DataPath, s.metadata.Fingerprint)
344+
s.logger.Printf("fixture '%s' fingerprint set to '%s' with asOf time %s ", s.metadata.DataPath, s.metadata.Fingerprint, s.metadata.FingerprintTime)
342345
return nil
343346
}

0 commit comments

Comments
 (0)