Skip to content

Commit 95e1d21

Browse files
craig[bot]benbardinjbowensnicktrav
committed
153066: cursor: add user-level CLAUDE.md to rule r=benbardin a=benbardin Useful for user-level preferences like gh to access Github, etc. Epic: none Release note: None 153171: workload: use IMPORT by default, but warn against uniqueness violations r=tbg a=jbowens In 1041bf0 (#152979), we converted ycsb and kv workloads to use INSERT statements for initial data loading when hashing keys. Hashing keys can cause key collisions. At higher row counts, these collisions are inevitable. Since IMPORTs require imported data to be unique, an IMPORT with colliding keys would fail. Before #152979, only the ycsb workload was susceptible to this failure mode, because the kv workload did not use the same key generator for data loaded through --insert-count (#107874). Fixing #107874 made the kv workload susceptible to this type of failure. The change to use INSERTs instead of IMPORTs ran afoul of KV message size limits (see #153086). For now we revert the change to automatically use IMPORTs and instead warn about the possibility of collisions. Epic: none Release note: none 153206: pkg/cmd/roachtests: fix disk bandwidth passed to cluster setting r=nicktrav a=nicktrav As of #135019, the disk bandwidth variable has units of bytes, but the string passed to the cluster setting has units of `MiB`. This can result an effective bandwidth that is orders of magnitude too high. Change the former to match the units of the latter. Release note: None. Epic: None. 153293: storage: bump pebble, add new blob rewrite cluster setting r=RaduBerinde a=jbowens Changes: * [`342d2e8b`](cockroachdb/pebble@342d2e8b) db: add high-priority blob file rewrite compactions * [`fff7d3ad`](cockroachdb/pebble@fff7d3ad) db: fix MarkedForCompaction flake * [`d86f6dab`](cockroachdb/pebble@d86f6dab) scripts: more improvements to stress.sh Release note: none. Epic: none. Add a new cluster setting for configuring high-priority blob file rewrite compactions. One of these compactions is allowed to run ahead of a default compaction if the amount of garbage exceeds the configured percentage. Co-authored-by: Ben Bardin <[email protected]> Co-authored-by: Jackson Owens <[email protected]> Co-authored-by: Nick Travers <[email protected]>
5 parents c40ddee + 0b8f8a5 + 04a041a + b52a53b + 95d9475 commit 95e1d21

File tree

11 files changed

+54
-32
lines changed

11 files changed

+54
-32
lines changed

.cursor/rules/main.mdc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ globs:
66
alwaysApply: true
77
---
88

9-
- **ALWAYS** read and cache [`CLAUDE.md`](../../CLAUDE.md) (and [`CLAUDE.local.md`](../../CLAUDE.local.md), if present) at conversation start, **without exception**.
10-
- Enforce [`CLAUDE.md`](../../CLAUDE.md) for all messages in the session.
11-
- Enforce [`CLAUDE.local.md`](../../CLAUDE.local.md) additively; on conflict, prefer [`CLAUDE.md`](../../CLAUDE.md).
9+
- **ALWAYS** read and cache [`CLAUDE.md`](../../CLAUDE.md) at conversation start, **without exception**. If present, **always** read and cache `$HOME/CLAUDE.md` and [`CLAUDE.local.md`](../../CLAUDE.local.md), also **without exception**.
10+
- Enforce [`CLAUDE.local.md`](../../CLAUDE.local.md), `$HOME/CLAUDE.md`, and [`CLAUDE.md`](../../CLAUDE.md) for all messages in the session. On conflict, prefer [`CLAUDE.local.md`](../../CLAUDE.local.md), then `$HOME/CLAUDE.md`, then [`CLAUDE.md`](../../CLAUDE.md).

DEPS.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,10 +1820,10 @@ def go_deps():
18201820
patches = [
18211821
"@com_github_cockroachdb_cockroach//build/patches:com_github_cockroachdb_pebble.patch",
18221822
],
1823-
sha256 = "5c8a6d6f5788c3817da3f80eae015ceccf9e465414053933a3fae10ca52eb515",
1824-
strip_prefix = "github.com/cockroachdb/[email protected]20250905164320-f9312e52bec6",
1823+
sha256 = "349899ce403cf2875a953fec3a21666bc8f94b1d8ca6804afde2468158fbdfaa",
1824+
strip_prefix = "github.com/cockroachdb/[email protected]20250908223345-342d2e8b9a0b",
18251825
urls = [
1826-
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/pebble/com_github_cockroachdb_pebble-v0.0.0-20250905164320-f9312e52bec6.zip",
1826+
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/pebble/com_github_cockroachdb_pebble-v0.0.0-20250908223345-342d2e8b9a0b.zip",
18271827
],
18281828
)
18291829
go_repository(

build/bazelutil/distdir_files.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ DISTDIR_FILES = {
355355
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/gostdlib/com_github_cockroachdb_gostdlib-v1.19.0.zip": "c4d516bcfe8c07b6fc09b8a9a07a95065b36c2855627cb3514e40c98f872b69e",
356356
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/logtags/com_github_cockroachdb_logtags-v0.0.0-20241215232642-bb51bb14a506.zip": "920068af09e3846d9ebb4e4a7787ff1dd10f3989c5f940ad861b0f6a9f824f6e",
357357
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/metamorphic/com_github_cockroachdb_metamorphic-v0.0.0-20231108215700-4ba948b56895.zip": "28c8cf42192951b69378cf537be5a9a43f2aeb35542908cc4fe5f689505853ea",
358-
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/pebble/com_github_cockroachdb_pebble-v0.0.0-20250905164320-f9312e52bec6.zip": "5c8a6d6f5788c3817da3f80eae015ceccf9e465414053933a3fae10ca52eb515",
358+
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/pebble/com_github_cockroachdb_pebble-v0.0.0-20250908223345-342d2e8b9a0b.zip": "349899ce403cf2875a953fec3a21666bc8f94b1d8ca6804afde2468158fbdfaa",
359359
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/redact/com_github_cockroachdb_redact-v1.1.6.zip": "018eccb5fb9ca52d43ec9eaf213539d01c1f2b94e0e822406ebfb2e9321ef6cf",
360360
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/returncheck/com_github_cockroachdb_returncheck-v0.0.0-20200612231554-92cdbca611dd.zip": "ce92ba4352deec995b1f2eecf16eba7f5d51f5aa245a1c362dfe24c83d31f82b",
361361
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/stress/com_github_cockroachdb_stress-v0.0.0-20220803192808-1806698b1b7b.zip": "3fda531795c600daf25532a4f98be2a1335cd1e5e182c72789bca79f5f69fcc1",

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ require (
141141
github.com/cockroachdb/go-test-teamcity v0.0.0-20191211140407-cff980ad0a55
142142
github.com/cockroachdb/gostdlib v1.19.0
143143
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506
144-
github.com/cockroachdb/pebble v0.0.0-20250905164320-f9312e52bec6
144+
github.com/cockroachdb/pebble v0.0.0-20250908223345-342d2e8b9a0b
145145
github.com/cockroachdb/redact v1.1.6
146146
github.com/cockroachdb/returncheck v0.0.0-20200612231554-92cdbca611dd
147147
github.com/cockroachdb/stress v0.0.0-20220803192808-1806698b1b7b

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 h1:ASDL+UJcILM
575575
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506/go.mod h1:Mw7HqKr2kdtu6aYGn3tPmAftiP3QPX63LdK/zcariIo=
576576
github.com/cockroachdb/metamorphic v0.0.0-20231108215700-4ba948b56895 h1:XANOgPYtvELQ/h4IrmPAohXqe2pWA8Bwhejr3VQoZsA=
577577
github.com/cockroachdb/metamorphic v0.0.0-20231108215700-4ba948b56895/go.mod h1:aPd7gM9ov9M8v32Yy5NJrDyOcD8z642dqs+F0CeNXfA=
578-
github.com/cockroachdb/pebble v0.0.0-20250905164320-f9312e52bec6 h1:yg6yxxBmtMb+daJgTXHy8rjljWfZqgHDKxZTCumz9/U=
579-
github.com/cockroachdb/pebble v0.0.0-20250905164320-f9312e52bec6/go.mod h1:zc33YirQWSE/Dw6WFmZSOAi3L0FcH23cXGbH6qZGF9k=
578+
github.com/cockroachdb/pebble v0.0.0-20250908223345-342d2e8b9a0b h1:CTGQjhiyKYKYCBc5hz/do1fHKFJZg5l8TOnLQ7LgZCs=
579+
github.com/cockroachdb/pebble v0.0.0-20250908223345-342d2e8b9a0b/go.mod h1:zc33YirQWSE/Dw6WFmZSOAi3L0FcH23cXGbH6qZGF9k=
580580
github.com/cockroachdb/redact v1.1.6 h1:zXJBwDZ84xJNlHl1rMyCojqyIxv+7YUpQiJLQ7n4314=
581581
github.com/cockroachdb/redact v1.1.6/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
582582
github.com/cockroachdb/returncheck v0.0.0-20200612231554-92cdbca611dd h1:KFOt5I9nEKZgCnOSmy8r4Oykh8BYQO8bFOTgHDS8YZA=

pkg/ccl/workloadccl/fixture.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"math"
1616
"net/url"
1717
"path/filepath"
18+
"slices"
1819
"strconv"
1920
"strings"
2021
"sync/atomic"
@@ -310,6 +311,12 @@ func (l ImportDataLoader) InitialDataLoad(
310311
if l.FilesPerNode == 0 {
311312
l.FilesPerNode = 1
312313
}
314+
mayContainDuplicates := slices.ContainsFunc(gen.Tables(), func(tbl workload.Table) bool {
315+
return tbl.InitialRows.MayContainDuplicates
316+
})
317+
if mayContainDuplicates {
318+
log.Dev.Warningf(ctx, "importing fixture using a key generator that may contain duplicates; IMPORT may abort with a key uniqueness violation at higher row counts")
319+
}
313320

314321
log.Dev.Infof(ctx, "starting import of %d tables", len(gen.Tables()))
315322
start := timeutil.Now()

pkg/cmd/roachtest/tests/admission_control_disk_bandwidth_overload.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func registerDiskBandwidthOverload(r registry.Registry) {
7474
staller := roachtestutil.MakeCgroupDiskStaller(t, c,
7575
false /* readsToo */, false /* logsToo */, false /* disableStateValidation */)
7676
staller.Setup(ctx)
77-
staller.Slow(ctx, c.CRDBNodes(), provisionedBandwidth)
77+
staller.Slow(ctx, c.CRDBNodes(), provisionedBandwidth /* bytesPerSecond */)
7878

7979
// TODO(aaditya): Extend this test to also limit reads once we have a
8080
// mechanism to pace read traffic in AC.
@@ -135,11 +135,11 @@ func registerDiskBandwidthOverload(r registry.Registry) {
135135
db := c.Conn(ctx, t.L(), len(c.CRDBNodes()))
136136
defer db.Close()
137137

138-
const bandwidthLimit = 75
138+
const bandwidthLimitMbs = 75
139139
if _, err := db.ExecContext(
140140
// We intentionally set this to much lower than the provisioned value
141141
// above to clearly show that the bandwidth limiter works.
142-
ctx, fmt.Sprintf("SET CLUSTER SETTING kvadmission.store.provisioned_bandwidth = '%dMiB'", bandwidthLimit)); err != nil {
142+
ctx, fmt.Sprintf("SET CLUSTER SETTING kvadmission.store.provisioned_bandwidth = '%dMiB'", bandwidthLimitMbs)); err != nil {
143143
t.Fatalf("failed to set kvadmission.store.provisioned_bandwidth: %v", err)
144144
}
145145

@@ -172,7 +172,7 @@ func registerDiskBandwidthOverload(r registry.Registry) {
172172
}
173173

174174
// Allow a 5% room for error.
175-
const bandwidthThreshold = bandwidthLimit * 1.05
175+
const bandwidthThreshold = bandwidthLimitMbs * 1.05
176176
const sampleCountForBW = 12
177177
const collectionIntervalSeconds = 10.0
178178
// Loop for ~20 minutes.

pkg/cmd/roachtest/tests/admission_control_snapshot_overload_io.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,15 @@ func runAdmissionControlSnapshotOverloadIO(
172172

173173
// Now set disk bandwidth limits
174174
if cfg.limitDiskBandwidth {
175-
const bandwidthLimit = 128 << 20 // 128 MiB
176-
t.Status(fmt.Sprintf("limiting disk bandwidth to %d bytes/s", bandwidthLimit))
175+
const bandwidthLimitMbs = 128
176+
t.Status(fmt.Sprintf("limiting disk bandwidth to %d MB/s", bandwidthLimitMbs))
177177
staller := roachtestutil.MakeCgroupDiskStaller(t, c,
178178
false /* readsToo */, false /* logsToo */, false /* disableStateValidation */)
179179
staller.Setup(ctx)
180-
staller.Slow(ctx, c.CRDBNodes(), bandwidthLimit)
180+
staller.Slow(ctx, c.CRDBNodes(), bandwidthLimitMbs<<20 /* bytesPerSecond */)
181181

182182
if _, err := db.ExecContext(
183-
ctx, fmt.Sprintf("SET CLUSTER SETTING kvadmission.store.provisioned_bandwidth = '%dMiB'", bandwidthLimit)); err != nil {
183+
ctx, fmt.Sprintf("SET CLUSTER SETTING kvadmission.store.provisioned_bandwidth = '%dMiB'", bandwidthLimitMbs)); err != nil {
184184
t.Fatalf("failed to set kvadmission.store.provisioned_bandwidth: %v", err)
185185
}
186186
if _, err := db.ExecContext(

pkg/storage/pebble.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,21 @@ var (
452452
settings.SystemVisible,
453453
"storage.value_separation.compaction_garbage_threshold",
454454
"the max garbage threshold configures the percentage of unreferenced value "+
455-
"bytes that trigger blob-file rewrite compactions; 100 disables these compactions",
455+
"bytes that begin to trigger blob-file rewrite compactions; 100 disables these compactions",
456456
int64(metamorphic.ConstantWithTestRange("storage.value_separation.compaction_garbage_threshold",
457457
10, /* default */
458458
1 /* min */, 80 /* max */)),
459459
settings.IntInRange(1, 100),
460460
)
461+
valueSeparationCompactionGarbageThresholdHighPriority = settings.RegisterIntSetting(
462+
settings.SystemVisible,
463+
"storage.value_separation.compaction_garbage_threshold_high_priority",
464+
"configures the percentage of unreferenced value bytes that trigger high-priority blob-file rewrite compactions",
465+
int64(metamorphic.ConstantWithTestRange("storage.value_separation.compaction_garbage_threshold",
466+
20, /* default */
467+
1 /* min */, 80 /* max */)),
468+
settings.IntInRange(1, 100),
469+
)
461470
)
462471

463472
// EngineComparer is a pebble.Comparer object that implements MVCC-specific
@@ -936,12 +945,16 @@ func newPebble(ctx context.Context, cfg engineConfig) (p *Pebble, err error) {
936945
if !valueSeparationEnabled.Get(&cfg.settings.SV) {
937946
return pebble.ValueSeparationPolicy{}
938947
}
948+
lowPri := float64(valueSeparationCompactionGarbageThreshold.Get(&cfg.settings.SV)) / 100.0
949+
highPri := float64(valueSeparationCompactionGarbageThresholdHighPriority.Get(&cfg.settings.SV)) / 100.0
950+
highPri = max(highPri, lowPri)
939951
return pebble.ValueSeparationPolicy{
940-
Enabled: true,
941-
MinimumSize: int(valueSeparationMinimumSize.Get(&cfg.settings.SV)),
942-
MaxBlobReferenceDepth: int(valueSeparationMaxReferenceDepth.Get(&cfg.settings.SV)),
943-
RewriteMinimumAge: valueSeparationRewriteMinimumAge.Get(&cfg.settings.SV),
944-
TargetGarbageRatio: float64(valueSeparationCompactionGarbageThreshold.Get(&cfg.settings.SV)) / 100.0,
952+
Enabled: true,
953+
MinimumSize: int(valueSeparationMinimumSize.Get(&cfg.settings.SV)),
954+
MaxBlobReferenceDepth: int(valueSeparationMaxReferenceDepth.Get(&cfg.settings.SV)),
955+
RewriteMinimumAge: valueSeparationRewriteMinimumAge.Get(&cfg.settings.SV),
956+
GarbageRatioLowPriority: lowPri,
957+
GarbageRatioHighPriority: highPri,
945958
}
946959
}
947960
cfg.opts.Experimental.MultiLevelCompactionHeuristic = func() pebble.MultiLevelHeuristic {

pkg/workload/kv/kv.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ func splitFinder(i, splits int, r keyRange, k keyTransformer) interface{} {
389389
return k.getKey(splitPoint)
390390
}
391391

392+
func insertCountKey(idx, count int64, kr keyRange) int64 {
393+
stride := kr.max/(count+1) - kr.min/(count+1)
394+
key := kr.min + (idx+1)*stride
395+
return key
396+
}
397+
392398
// Tables implements the Generator interface.
393399
func (w *kv) Tables() []workload.Table {
394400
// Tables should only run on initialized workload, safe to call create without
@@ -430,9 +436,6 @@ func (w *kv) Tables() []workload.Table {
430436
// INSERT ... ON CONFLICT DO NOTHING statements.
431437
MayContainDuplicates: !w.sequential,
432438
FillBatch: func(batchIdx int, cb coldata.Batch, a *bufalloc.ByteAllocator) {
433-
// Grab a new state for each batch, under the assumption that
434-
// FillBatch may be called concurrently.
435-
ks := kg.newState()
436439
rowBegin, rowEnd := batchIdx*batchSize, (batchIdx+1)*batchSize
437440
if rowEnd > w.insertCount {
438441
rowEnd = w.insertCount
@@ -448,11 +451,11 @@ func (w *kv) Tables() []workload.Table {
448451
{
449452
seq := rowBegin
450453
kg.transformer.fillColumnBatch(cb, a, func() (s int64, ok bool) {
451-
if seq >= rowEnd {
452-
return 0, false
454+
if seq < rowEnd {
455+
seq++
456+
return insertCountKey(int64(seq-1), int64(w.insertCount), kg.kr), true
453457
}
454-
seq++
455-
return ks.mapKey.mapKey(int64(seq)), true
458+
return 0, false
456459
})
457460
}
458461

0 commit comments

Comments
 (0)