From 29bf82f9cec31b029d2f6a3a06f53dff7544243a Mon Sep 17 00:00:00 2001 From: Annie Pompa Date: Wed, 16 Aug 2023 20:12:22 -0400 Subject: [PATCH] sql: deflake TestDropTableWhileUpgradingFormat 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 --- pkg/sql/drop_test.go | 7 ++++++- pkg/sql/tests/data.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/sql/drop_test.go b/pkg/sql/drop_test.go index 4cc51e662aaa..6adb2efc2cbf 100644 --- a/pkg/sql/drop_test.go +++ b/pkg/sql/drop_test.go @@ -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`) diff --git a/pkg/sql/tests/data.go b/pkg/sql/tests/data.go index 42a2e9c20d95..dfb1dd32e53f 100644 --- a/pkg/sql/tests/data.go +++ b/pkg/sql/tests/data.go @@ -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()