Skip to content

Commit ff83aa1

Browse files
committed
roachtest: fail on bad table lookup when fingerprinting fixtures
Some fixtures are missing table fingerprints, which results in failing restore roachtests. However, the failure is actually caused by bad fixture fingerprints, which were silently ignored due to the fact that we simply log an error and continue if we are unable to fetch all tables of a database. This commit updates the roachtest to properly fail if we fail to fetch a table. Informs: #149555, #149556, #149557, #149558, #149559, #149560, #149561
1 parent 55d7fbb commit ff83aa1

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

pkg/cmd/roachtest/tests/backup_fixtures.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,7 @@ func (bd *backupDriver) fingerprintFixture(ctx context.Context) map[string]strin
415415
conn := bd.c.Conn(ctx, bd.t.L(), 1)
416416
defer conn.Close()
417417
return fingerprintDatabase(
418-
ctx, bd.t, conn,
419-
bd.sp.fixture.DatabaseName(), bd.getLatestAOST(sqlutils.MakeSQLRunner(conn)),
418+
bd.t, conn, bd.sp.fixture.DatabaseName(), bd.getLatestAOST(sqlutils.MakeSQLRunner(conn)),
420419
)
421420
}
422421

@@ -440,10 +439,10 @@ func (bd *backupDriver) getLatestAOST(sql *sqlutils.SQLRunner) string {
440439
// and returns a map of fully qualified table names to their fingerprints.
441440
// If AOST is not provided, the current time is used as the AOST.
442441
func fingerprintDatabase(
443-
ctx context.Context, t test.Test, conn *gosql.DB, dbName string, aost string,
442+
t test.Test, conn *gosql.DB, dbName string, aost string,
444443
) map[string]string {
445444
sql := sqlutils.MakeSQLRunner(conn)
446-
tables := getDatabaseTables(ctx, t, sql, dbName)
445+
tables := getDatabaseTables(t, sql, dbName)
447446
if len(tables) == 0 {
448447
t.L().Printf("no tables found in database %s", dbName)
449448
return nil
@@ -480,9 +479,7 @@ func fingerprintDatabase(
480479
// fixture.
481480
// Note: This assumes there aren't any funky characters in the identifiers, so
482481
// nothing is SQL-escaped.
483-
func getDatabaseTables(
484-
ctx context.Context, t test.Test, sql *sqlutils.SQLRunner, db string,
485-
) []string {
482+
func getDatabaseTables(t test.Test, sql *sqlutils.SQLRunner, db string) []string {
486483
tablesQuery := fmt.Sprintf(`SELECT schema_name, table_name FROM [SHOW TABLES FROM %s]`, db)
487484
rows := sql.Query(t, tablesQuery)
488485
defer rows.Close()
@@ -491,8 +488,7 @@ func getDatabaseTables(
491488
for rows.Next() {
492489
var schemaName, tableName string
493490
if err := rows.Scan(&schemaName, &tableName); err != nil {
494-
t.L().Printf("error scanning table name: %v", err)
495-
continue
491+
require.NoError(t, err, "error scanning table name")
496492
}
497493
tables = append(tables, fmt.Sprintf(`%s.%s.%s`, db, schemaName, tableName))
498494
}

pkg/cmd/roachtest/tests/restore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ func (rd *restoreDriver) maybeValidateFingerprint(ctx context.Context) {
931931
require.NoError(rd.t, err)
932932
defer conn.Close()
933933
fingerprint := fingerprintDatabase(
934-
ctx, rd.t, conn, rd.sp.backup.fixture.DatabaseName(), "", /* aost */
934+
rd.t, conn, rd.sp.backup.fixture.DatabaseName(), "", /* aost */
935935
)
936936
require.Equal(rd.t, rd.fixtureMetadata.Fingerprint, fingerprint, "fingerprint mismatch after restore")
937937
}

0 commit comments

Comments
 (0)