From 92ce01be12acc56230200a516ca39068355d3dc8 Mon Sep 17 00:00:00 2001 From: Nikhil Benesch Date: Mon, 22 Oct 2018 11:26:26 -0400 Subject: [PATCH] partitionccl: deflake TestDropIndexWithZoneConfigCCL A particularly adversarial goroutine schedule can cause this test to observe the moment in time where the data is dropped but the zone config is not. Deflake by retrying the check for the dropped zone config until it succeeds (or times out). Fix #31678. Release note: None --- pkg/ccl/partitionccl/drop_test.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/ccl/partitionccl/drop_test.go b/pkg/ccl/partitionccl/drop_test.go index 49b81e46f3c9..1f69dba3817b 100644 --- a/pkg/ccl/partitionccl/drop_test.go +++ b/pkg/ccl/partitionccl/drop_test.go @@ -10,6 +10,7 @@ package partitionccl import ( "context" + "fmt" "testing" "github.com/pkg/errors" @@ -124,19 +125,18 @@ func TestDropIndexWithZoneConfigCCL(t *testing.T) { } else if l := 0; len(kvs) != l { return errors.Errorf("expected %d key value pairs, but got %d", l, len(kvs)) } + sqlDB.QueryRow(t, "SELECT config FROM system.zones WHERE id = $1", tableDesc.ID).Scan(&buf) + if err := protoutil.Unmarshal(buf, cfg); err != nil { + return err + } + if exists := subzoneExists(cfg, 1, ""); !exists { + return errors.New("zone config for primary index removed after dropping secondary index") + } + for _, target := range subzones[1:] { + if exists := subzoneExists(cfg, target.index, target.partition); exists { + return fmt.Errorf(`zone config for %v still exists`, target) + } + } return nil }) - - sqlDB.QueryRow(t, "SELECT config FROM system.zones WHERE id = $1", tableDesc.ID).Scan(&buf) - if err := protoutil.Unmarshal(buf, cfg); err != nil { - t.Fatal(err) - } - if exists := subzoneExists(cfg, 1, ""); !exists { - t.Fatal("zone config for primary index removed after dropping secondary index") - } - for _, target := range subzones[1:] { - if exists := subzoneExists(cfg, target.index, target.partition); exists { - t.Fatalf(`zone config for %v still exists`, target) - } - } }