Skip to content

Commit

Permalink
coldata: fix recent flaky behavior
Browse files Browse the repository at this point in the history
In a just merged b353d18 when
addressing the PR feedback I introduced a possibility of a crash in
tests. In particular, this can occur if we choose to randomize
`coldata.BatchSize` value larger than the default (or if the test
explicitly overrides it). The problem is that `BatchSize()` can return
different values in `init()` of `coldata` package and during the test
runs, so we now use `MaxBatchSize` where applicable.

Release note: None
  • Loading branch information
yuzefovich committed Jan 3, 2023
1 parent fbd7b8b commit cb96d6b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/col/coldata/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func (b *Bytes) elementsAsBytes(n int) []byte {
var zeroInt32Slice []int32

func init() {
zeroInt32Slice = make([]int32, BatchSize())
zeroInt32Slice = make([]int32, MaxBatchSize)
}

// Serialize converts b into the "arrow-like" (which is arrow-compatible)
Expand All @@ -579,7 +579,7 @@ func init() {
// buffer = [<b.elements as []byte><b.buffer]
// offsets = [0, 0, ..., 0, len(<b.elements as []byte>), len(<b.elements as []byte>) + len(buffer)]
//
// Note: it is assumed that n is not larger than BatchSize().
// Note: it is assumed that n is not larger than MaxBatchSize.
func (b *Bytes) Serialize(n int, dataScratch []byte, offsetsScratch []int32) ([]byte, []int32) {
if buildutil.CrdbTestBuild {
if n > BatchSize() {
Expand Down

0 comments on commit cb96d6b

Please sign in to comment.