Skip to content

Commit 4751ee7

Browse files
yuzefovichclaude
andcommitted
kv/bulk: make maxSlabGrow configurable for large KV entries
Adds COCKROACH_KV_BULK_MAX_SLAB_GROW environment variable to override the default 64 MiB limit for rare cases with very large KV entries. Fixes #150181 Release note: None 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 73f993e commit 4751ee7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pkg/kv/bulk/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ go_library(
2727
"//pkg/util/admission/admissionpb",
2828
"//pkg/util/buildutil",
2929
"//pkg/util/ctxgroup",
30+
"//pkg/util/envutil",
3031
"//pkg/util/hlc",
3132
"//pkg/util/humanizeutil",
3233
"//pkg/util/limit",

pkg/kv/bulk/kv_buf.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"context"
1111

1212
"github.com/cockroachdb/cockroach/pkg/roachpb"
13+
"github.com/cockroachdb/cockroach/pkg/util/envutil"
1314
"github.com/cockroachdb/cockroach/pkg/util/mon"
1415
"github.com/cockroachdb/errors"
1516
)
@@ -38,7 +39,9 @@ const entrySizeShift = 4 // sizeof(kvBufEntry) is 16, or shift 4.
3839
const minEntryGrow = 1 << 14 // 16k items or 256KiB of entry size.
3940
const maxEntryGrow = (4 << 20) >> entrySizeShift
4041
const minSlabGrow = 512 << 10
41-
const maxSlabGrow = 64 << 20
42+
const defaultMaxSlabGrow = 64 << 20 // 64MiB
43+
44+
var maxSlabGrow = sz(envutil.EnvOrDefaultInt64("COCKROACH_KV_BULK_MAX_SLAB_GROW", defaultMaxSlabGrow))
4245

4346
const (
4447
lenBits, lenMask = 28, 1<<lenBits - 1 // 512mb item limit, 32gb buffer limit.

0 commit comments

Comments
 (0)