Skip to content

Commit 545ce2c

Browse files
craig[bot]jeffswensonpav-kv
committed
157939: ldrrandgen: recursively check types for refcursor r=jeffswenson a=jeffswenson This adjusts the ldr table generator to avoid generating random types that contain a refcursor. Release note: none Fixes: #157026 158062: kvserver: print GOMAXPROCS in slow test r=pav-kv a=pav-kv Informs #156293 Co-authored-by: Jeff Swenson <[email protected]> Co-authored-by: Pavel Kalinnikov <[email protected]>
3 parents f87a3c8 + ddfe217 + b23b931 commit 545ce2c

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

pkg/crosscluster/ldrrandgen/logical.go

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,30 @@ import (
1515
"github.com/cockroachdb/cockroach/pkg/sql/types"
1616
)
1717

18+
func isSupportedType(t *types.T) bool {
19+
switch t.Family() {
20+
case types.RefCursorFamily:
21+
// We don't support RefCursor columns in LDR tables because they do not
22+
// support equality.
23+
return false
24+
case types.ArrayFamily:
25+
// We don't allow Arrays of bits because rand.LoadTable doesn't correctly identify their bit width.
26+
if t.ArrayContents().Family() == types.BitFamily {
27+
return false
28+
}
29+
return isSupportedType(t.ArrayContents())
30+
case types.TupleFamily:
31+
for _, elemType := range t.TupleContents() {
32+
if !isSupportedType(elemType) {
33+
return false
34+
}
35+
}
36+
return true
37+
default:
38+
return true
39+
}
40+
}
41+
1842
func GenerateLDRTable(
1943
ctx context.Context, rng *rand.Rand, tableName string, supportKVWriter bool,
2044
) *tree.CreateTable {
@@ -31,21 +55,7 @@ func GenerateLDRTable(
3155
randgen.WithPrimaryIndexRequired(),
3256
randgen.WithSkipColumnFamilyMutations(),
3357
randgen.WithColumnFilter(func(columnDef *tree.ColumnTableDef) bool {
34-
// We don't allow Arrays of bits because rand.LoadTable doesn't correctly identify their bit width.
35-
if columnDef.Type.(*types.T).Family() == types.ArrayFamily && columnDef.Type.(*types.T).ArrayContents().Family() == types.BitFamily {
36-
return false
37-
}
38-
// We don't support RefCursor columns in LDR tables because they do not
39-
// support equality.
40-
if columnDef.Type.(*types.T).Family() == types.RefCursorFamily {
41-
return false
42-
}
43-
// We don't allow the special '"char"' column because pgwire truncates the value to 1 byte.
44-
// TODO(jeffswenson): remove this once #149427 is fixed.
45-
if columnDef.Type.(*types.T).Family() == types.StringFamily && columnDef.Type.(*types.T).Width() == 1 {
46-
return false
47-
}
48-
return true
58+
return isSupportedType(columnDef.Type.(*types.T))
4959
}),
5060
randgen.WithPrimaryIndexFilter(func(indexDef *tree.IndexTableDef, columnDefs []*tree.ColumnTableDef) bool {
5161
for _, col := range indexDef.Columns {

pkg/kv/kvserver/replicate_queue_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"os"
1616
"path/filepath"
1717
"regexp"
18+
"runtime"
1819
"strconv"
1920
"strings"
2021
"sync/atomic"
@@ -221,8 +222,10 @@ func TestReplicateQueueRebalanceMultiStore(t *testing.T) {
221222
})
222223
}
223224
for _, testCase := range testCases {
224-
225225
t.Run(testCase.name, func(t *testing.T) {
226+
// TODO(pav-kv): remove this when we know why the test is too slow in CI.
227+
t.Logf("GOMAXPROCS: %d", runtime.GOMAXPROCS(0))
228+
226229
if testCase.storesPerNode > 1 {
227230
// 8 stores with active rebalancing can lead to failed heartbeats due
228231
// to overload. Skip under stress when running the multi-store variant.

0 commit comments

Comments
 (0)