Skip to content

Commit

Permalink
Merge pull request #131044 from fqazi/backport24.1-131018
Browse files Browse the repository at this point in the history
release-24.1: multiregionccl: deflake TestMrSystemDatabase
  • Loading branch information
fqazi authored Sep 19, 2024
2 parents e2c9e38 + b4d0b62 commit 77680b3
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions pkg/ccl/multiregionccl/multiregion_system_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,28 @@ func TestMrSystemDatabase(t *testing.T) {
tDB.CheckQueryResults(t, `SELECT * FROM crdb_internal.invalid_objects`, [][]string{})

t.Run("Sqlliveness", func(t *testing.T) {
row := tDB.QueryRow(t, `SELECT crdb_region, session_id, expiration FROM system.sqlliveness LIMIT 1`)
var sessionID string
var crdbRegion string
var rawExpiration apd.Decimal
row.Scan(&crdbRegion, &sessionID, &rawExpiration)
require.Equal(t, "us-east1", crdbRegion)
// When optimizing the system database the ALTER DATABASE command will
// delete stats, but these are refreshed in memory using a range feed.
// Since there can be a delay in the new stats being picked up its possible
// for this query to fail with:
// "unsupported comparison: bytes to crdb_internal_region"
// querying table statistics. This is a transient condition that will
// clear up once the range feed catches up.
testutils.SucceedsSoon(t, func() error {
row := tDB.DB.QueryRowContext(ctx, `SELECT crdb_region, session_id, expiration FROM system.sqlliveness LIMIT 1`)
var sessionID string
var crdbRegion string
var rawExpiration apd.Decimal
err := row.Scan(&crdbRegion, &sessionID, &rawExpiration)
if err != nil {
return err
}
if crdbRegion != "us-east1" {
return errors.AssertionFailedf("unexpected region, got: %q expected: %q",
crdbRegion, "us-east1")
}
return nil
})
})

t.Run("Sqlinstances", func(t *testing.T) {
Expand Down

0 comments on commit 77680b3

Please sign in to comment.