Skip to content

Commit 8e86378

Browse files
committed
db: respect EnableColumnarBlocks option on recent FMVs
Fix a bug that caused EnableColumnarBlocks to be ignored on recent format major versions. Later format major versions may require use of columnar blocks, but not any in use in CockroachDB v25.2.
1 parent 28fcae5 commit 8e86378

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

format_major_version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ func (d *DB) TableFormat() sstable.TableFormat {
380380
if d.opts.Experimental.EnableValueBlocks == nil || !d.opts.Experimental.EnableValueBlocks() {
381381
f = sstable.TableFormatPebblev2
382382
}
383-
case sstable.TableFormatPebblev5:
383+
case sstable.TableFormatPebblev5, sstable.TableFormatPebblev6:
384384
if d.opts.Experimental.EnableColumnarBlocks == nil || !d.opts.Experimental.EnableColumnarBlocks() {
385385
f = sstable.TableFormatPebblev4
386386
}

format_major_version_test.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,64 @@ func TestFormatMajorVersions_TableFormat(t *testing.T) {
239239
require.Panics(t, func() { _ = fmv.MaxTableFormat() })
240240
require.Panics(t, func() { _ = fmv.MinTableFormat() })
241241
}
242+
243+
// TestFormatMajorVersions_ColumnarBlocks ensures that
244+
// Experimental.EnableColumnarBlocks is respected on recent format major
245+
// versions.
246+
func TestFormatMajorVersions_ColumnarBlocks(t *testing.T) {
247+
type testCase struct {
248+
fmv FormatMajorVersion
249+
colBlks bool
250+
want sstable.TableFormat
251+
}
252+
testCases := []testCase{
253+
{
254+
fmv: FormatTableFormatV6,
255+
colBlks: true,
256+
want: sstable.TableFormatPebblev6,
257+
},
258+
{
259+
fmv: FormatTableFormatV6,
260+
colBlks: false,
261+
want: sstable.TableFormatPebblev4,
262+
},
263+
{
264+
fmv: FormatColumnarBlocks,
265+
colBlks: true,
266+
want: sstable.TableFormatPebblev5,
267+
},
268+
{
269+
fmv: FormatColumnarBlocks,
270+
colBlks: false,
271+
want: sstable.TableFormatPebblev4,
272+
},
273+
{
274+
fmv: FormatFlushableIngestExcises,
275+
colBlks: true,
276+
want: sstable.TableFormatPebblev4,
277+
},
278+
{
279+
fmv: FormatNewest,
280+
colBlks: false,
281+
want: sstable.TableFormatPebblev4,
282+
},
283+
{
284+
fmv: FormatNewest,
285+
colBlks: true,
286+
want: sstable.TableFormatPebblev6,
287+
},
288+
}
289+
for _, tc := range testCases {
290+
t.Run(fmt.Sprintf("(%s,%t)", tc.fmv, tc.colBlks), func(t *testing.T) {
291+
opts := &Options{
292+
FS: vfs.NewMem(),
293+
FormatMajorVersion: tc.fmv,
294+
}
295+
opts.Experimental.EnableColumnarBlocks = func() bool { return tc.colBlks }
296+
d, err := Open("", opts)
297+
require.NoError(t, err)
298+
defer func() { _ = d.Close() }()
299+
require.Equal(t, tc.want, d.TableFormat())
300+
})
301+
}
302+
}

iterator_histories_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestIterHistories(t *testing.T) {
5454
},
5555
Logger: testLogger{t},
5656
}
57-
57+
opts.Experimental.EnableColumnarBlocks = func() bool { return true }
5858
opts.DisableAutomaticCompactions = true
5959
opts.EnsureDefaults()
6060
opts.WithFSDefaults()

metrics_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ func TestMetrics(t *testing.T) {
150150
MaxOpenFiles: 10000,
151151
}
152152
opts.Experimental.EnableValueBlocks = func() bool { return true }
153+
opts.Experimental.EnableColumnarBlocks = func() bool { return true }
153154
opts.Levels = append(opts.Levels, LevelOptions{TargetFileSize: 50})
154155

155156
// Prevent foreground flushes and compactions from triggering asynchronous

0 commit comments

Comments
 (0)