Skip to content

Commit

Permalink
partitionccl: deflake TestDropIndexWithZoneConfigCCL
Browse files Browse the repository at this point in the history
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 cockroachdb#31678.

Release note: None
  • Loading branch information
benesch committed Oct 22, 2018
1 parent 2998190 commit 92ce01b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions pkg/ccl/partitionccl/drop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package partitionccl

import (
"context"
"fmt"
"testing"

"github.com/pkg/errors"
Expand Down Expand Up @@ -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)
}
}
}

0 comments on commit 92ce01b

Please sign in to comment.