Skip to content

Commit

Permalink
Merge #108880
Browse files Browse the repository at this point in the history
108880: sql: deflake TestDropTableWhileUpgradingFormat r=annrpom a=annrpom

Previously, the `CheckKeyCountIncludingTombstoned` call in TestDropTableWhileUpgradingFormat flaked with a key count mismatch error (expected: 100, actual: 0). This was odd because this key counting failure was directly after rows were committed. To address this, this patch adds a retry for the `CheckKeyCountIncludingTombstoned` logic in case this is due to a race condition.

Epic: none
Fixes: #108340

Release note (sql change): deflake TestDropTableWhileUpgradingFormat

Co-authored-by: Annie Pompa <annie@cockroachlabs.com>
  • Loading branch information
craig[bot] and annrpom committed Aug 17, 2023
2 parents 8d5ff3f + 29bf82f commit a0c30d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/sql/drop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,12 @@ func TestDropTableWhileUpgradingFormat(t *testing.T) {
}

tableSpan := tableDesc.TableSpan(keys.SystemSQLCodec)
tests.CheckKeyCountIncludingTombstoned(t, s, tableSpan, numRows)
testutils.SucceedsSoon(t, func() error {
if err := tests.CheckKeyCountIncludingTombstonedE(t, s, tableSpan, numRows); err != nil {
return errors.Wrap(err, "failed to verify expected amount of keys")
}
return nil
})

sqlDB.Exec(t, `DROP TABLE test.t`)

Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/tests/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func CheckKeyCountIncludingTombstoned(
}
}

// CheckKeyCountE returns an error if the the number of keys in the
// CheckKeyCountE returns an error if the number of keys in the
// provided span does not match numKeys.
func CheckKeyCountE(t *testing.T, kvDB *kv.DB, span roachpb.Span, numKeys int) error {
t.Helper()
Expand Down

0 comments on commit a0c30d2

Please sign in to comment.