Skip to content

Commit 9ccbc4f

Browse files
craig[bot]petermattisbobvawter
committed
Merge #41901 #41993
41901: storage/engine: centralize specification of pebble.Options r=petermattis a=petermattis Fixes #41860 Release note: None 41993: build: Upgrade to go 1.12.12 r=bobvawter a=bobvawter This change upgrades the go runtime to 1.12.12 in order to pick up a [security fix](golang/go#34960). Per the [checklist](build/README.md): * [X] Adjust version in Docker image * [X] Rebuild the Docker image and bump the version in builder.sh accordingly * [ ] ~Bump the version in go-version-check.sh~ (Patch release, not necessary) * [X] Bump the default installed version of Go in bootstrap-debian.sh Fixes: #41718 Release note (build change): The go runtime has been upgraded to 1.12.12. Co-authored-by: Peter Mattis <[email protected]> Co-authored-by: Bob Vawter <[email protected]>
3 parents a3a6c11 + 25b8acf + 6ff63ba commit 9ccbc4f

File tree

11 files changed

+88
-113
lines changed

11 files changed

+88
-113
lines changed

build/bootstrap/bootstrap-debian.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ echo '. ~/.bashrc_bootstrap' >> ~/.bashrc
3838

3939
# Install Go.
4040
trap 'rm -f /tmp/go.tgz' EXIT
41-
curl https://dl.google.com/go/go1.12.10.linux-amd64.tar.gz > /tmp/go.tgz
41+
curl https://dl.google.com/go/go1.12.12.linux-amd64.tar.gz > /tmp/go.tgz
4242
sha256sum -c - <<EOF
43-
aaa84147433aed24e70b31da369bb6ca2859464a45de47c2a5023d8573412f6b /tmp/go.tgz
43+
4cf11ac6a8fa42d26ab85e27a5d916ee171900a87745d9f7d4a29a21587d78fc /tmp/go.tgz
4444
EOF
4545
sudo tar -C /usr/local -zxf /tmp/go.tgz
4646

build/builder.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -euo pipefail
44

55
image=cockroachdb/builder
6-
version=20191014-135449
6+
version=20191029-105705
77

88
function init() {
99
docker build --tag="${image}" "$(dirname "${0}")/builder"

build/builder/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ RUN git clone git://git.sv.gnu.org/sed \
196196
# releases of Go will no longer be run in CI once it is changed. Consider
197197
# bumping the minimum allowed version of Go in /build/go-version-chech.sh.
198198
RUN apt-get install -y --no-install-recommends golang \
199-
&& curl -fsSL https://storage.googleapis.com/golang/go1.12.10.src.tar.gz -o golang.tar.gz \
200-
&& echo 'f56e48fce80646d3c94dcf36d3e3f490f6d541a92070ad409b87b6bbb9da3954 golang.tar.gz' | sha256sum -c - \
199+
&& curl -fsSL https://storage.googleapis.com/golang/go1.12.12.src.tar.gz -o golang.tar.gz \
200+
&& echo 'fcb33b5290fa9bcc52be3211501540df7483d7276b031fc77528672a3c705b99 golang.tar.gz' | sha256sum -c - \
201201
&& tar -C /usr/local -xzf golang.tar.gz \
202202
&& rm golang.tar.gz \
203203
&& cd /usr/local/go/src \

pkg/base/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,9 @@ type StorageConfig struct {
659659
// Makes no sense for in-memory instances.
660660
// TODO(hueypark): Implement this for pebble.
661661
MustExist bool
662+
// MaxSize is used for calculating free space and making rebalancing
663+
// decisions. Zero indicates that there is no maximum size.
664+
MaxSize int64
662665
// Settings instance for cluster-wide knobs.
663666
Settings *cluster.Settings
664667
// UseFileRegistry is true if the file registry is needed (eg: encryption-at-rest).

pkg/server/config.go

+4-14
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error) {
498498
storageConfig := base.StorageConfig{
499499
Attrs: spec.Attributes,
500500
Dir: spec.Path,
501+
MaxSize: sizeInBytes,
501502
Settings: cfg.Settings,
502503
UseFileRegistry: spec.UseFileRegistry,
503504
ExtraOptions: spec.ExtraOptions,
@@ -507,25 +508,14 @@ func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error) {
507508
// in the spec (similar to the existing spec.RocksDBOptions and others).
508509
pebbleConfig := engine.PebbleConfig{
509510
StorageConfig: storageConfig,
510-
Opts: &pebble.Options{
511-
Cache: pebbleCache,
512-
MaxOpenFiles: int(openFileLimitPerStore),
513-
MemTableSize: 64 << 20,
514-
MemTableStopWritesThreshold: 4,
515-
MinFlushRate: 4 << 20,
516-
L0CompactionThreshold: 2,
517-
L0StopWritesThreshold: 400,
518-
LBaseMaxBytes: 64 << 20, // 64 MB
519-
Levels: []pebble.LevelOptions{{
520-
BlockSize: 32 << 10,
521-
}},
522-
},
511+
Opts: engine.DefaultPebbleOptions(),
523512
}
513+
pebbleConfig.Opts.Cache = pebbleCache
514+
pebbleConfig.Opts.MaxOpenFiles = int(openFileLimitPerStore)
524515
eng, err = engine.NewPebble(pebbleConfig)
525516
} else {
526517
rocksDBConfig := engine.RocksDBConfig{
527518
StorageConfig: storageConfig,
528-
MaxSizeBytes: sizeInBytes,
529519
MaxOpenFiles: openFileLimitPerStore,
530520
WarnLargeBatchThreshold: 500 * time.Millisecond,
531521
RocksDBOptions: spec.RocksDBOptions,

pkg/storage/engine/bench_pebble_test.go

+7-16
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,19 @@ import (
2020
"github.com/cockroachdb/pebble/vfs"
2121
)
2222

23-
func newPebbleOptions(fs vfs.FS) *pebble.Options {
24-
return &pebble.Options{
25-
Cache: pebble.NewCache(testCacheSize),
26-
FS: fs,
27-
MemTableSize: 64 << 20,
28-
MemTableStopWritesThreshold: 4,
29-
MinFlushRate: 4 << 20,
30-
L0CompactionThreshold: 2,
31-
L0StopWritesThreshold: 400,
32-
LBaseMaxBytes: 64 << 20, // 64 MB
33-
Levels: []pebble.LevelOptions{{
34-
BlockSize: 32 << 10,
35-
}},
36-
}
23+
func testPebbleOptions(fs vfs.FS) *pebble.Options {
24+
opts := DefaultPebbleOptions()
25+
opts.Cache = pebble.NewCache(testCacheSize)
26+
opts.FS = fs
27+
return opts
3728
}
3829

3930
func setupMVCCPebble(b testing.TB, dir string) Engine {
4031
peb, err := NewPebble(PebbleConfig{
4132
StorageConfig: base.StorageConfig{
4233
Dir: dir,
4334
},
44-
Opts: newPebbleOptions(vfs.Default),
35+
Opts: testPebbleOptions(vfs.Default),
4536
})
4637
if err != nil {
4738
b.Fatalf("could not create new pebble instance at %s: %+v", dir, err)
@@ -51,7 +42,7 @@ func setupMVCCPebble(b testing.TB, dir string) Engine {
5142

5243
func setupMVCCInMemPebble(b testing.TB, loc string) Engine {
5344
peb, err := NewPebble(PebbleConfig{
54-
Opts: newPebbleOptions(vfs.NewMem()),
45+
Opts: testPebbleOptions(vfs.NewMem()),
5546
})
5647
if err != nil {
5748
b.Fatalf("could not create new in-mem pebble instance: %+v", err)

pkg/storage/engine/engine_test.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"github.com/cockroachdb/cockroach/pkg/util/hlc"
3232
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
3333
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
34-
"github.com/cockroachdb/pebble"
3534
"github.com/cockroachdb/pebble/vfs"
3635
"github.com/pkg/errors"
3736
"github.com/stretchr/testify/assert"
@@ -70,9 +69,7 @@ func runWithAllEngines(test func(e Engine, t *testing.T), t *testing.T) {
7069

7170
func() {
7271
pebbleInMem, err := NewPebble(PebbleConfig{
73-
Opts: &pebble.Options{
74-
FS: vfs.NewMem(),
75-
},
72+
Opts: testPebbleOptions(vfs.NewMem()),
7673
})
7774
if err != nil {
7875
t.Fatal(err)

pkg/storage/engine/mvcc_test.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import (
3737
"github.com/cockroachdb/cockroach/pkg/util/randutil"
3838
"github.com/cockroachdb/cockroach/pkg/util/shuffle"
3939
"github.com/cockroachdb/cockroach/pkg/util/uuid"
40-
"github.com/cockroachdb/pebble"
4140
"github.com/cockroachdb/pebble/vfs"
4241
"github.com/gogo/protobuf/proto"
4342
"github.com/kr/pretty"
@@ -89,9 +88,7 @@ func createTestRocksDBEngine() Engine {
8988
// createTestPebbleEngine returns a new in-memory Pebble storage engine.
9089
func createTestPebbleEngine() Engine {
9190
peb, err := NewPebble(PebbleConfig{
92-
Opts: &pebble.Options{
93-
FS: vfs.NewMem(),
94-
},
91+
Opts: testPebbleOptions(vfs.NewMem()),
9592
})
9693
if err != nil {
9794
return nil

pkg/storage/engine/pebble.go

+25-11
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,29 @@ var PebbleTablePropertyCollectors = []func() pebble.TablePropertyCollector{
186186
func() pebble.TablePropertyCollector { return &pebbleDeleteRangeCollector{} },
187187
}
188188

189+
// DefaultPebbleOptions returns the default pebble options.
190+
func DefaultPebbleOptions() *pebble.Options {
191+
return &pebble.Options{
192+
Comparer: MVCCComparer,
193+
L0CompactionThreshold: 2,
194+
L0StopWritesThreshold: 1000,
195+
LBaseMaxBytes: 64 << 20, // 64 MB
196+
Levels: []pebble.LevelOptions{{
197+
BlockSize: 32 << 10, // 32 KB
198+
}},
199+
MemTableSize: 64 << 20, // 64 MB
200+
MemTableStopWritesThreshold: 4,
201+
Merger: MVCCMerger,
202+
MinFlushRate: 4 << 20, // 4 MB/sec
203+
TablePropertyCollectors: PebbleTablePropertyCollectors,
204+
}
205+
}
206+
189207
// PebbleConfig holds all configuration parameters and knobs used in setting up
190208
// a new Pebble instance.
191209
type PebbleConfig struct {
192210
// StorageConfig contains storage configs for all storage engines.
193-
StorageConfig base.StorageConfig
211+
base.StorageConfig
194212
// Pebble specific options.
195213
Opts *pebble.Options
196214
}
@@ -201,6 +219,7 @@ type Pebble struct {
201219

202220
closed bool
203221
path string
222+
maxSize int64
204223
attrs roachpb.Attributes
205224
settings *cluster.Settings
206225

@@ -212,10 +231,6 @@ var _ Engine = &Pebble{}
212231

213232
// NewPebble creates a new Pebble instance, at the specified path.
214233
func NewPebble(cfg PebbleConfig) (*Pebble, error) {
215-
cfg.Opts.Comparer = MVCCComparer
216-
cfg.Opts.Merger = MVCCMerger
217-
cfg.Opts.TablePropertyCollectors = PebbleTablePropertyCollectors
218-
219234
// pebble.Open also calls EnsureDefaults, but only after doing a clone. Call
220235
// EnsureDefaults beforehand so we have a matching cfg here for when we save
221236
// cfg.FS and cfg.ReadOnly later on.
@@ -228,9 +243,10 @@ func NewPebble(cfg PebbleConfig) (*Pebble, error) {
228243

229244
return &Pebble{
230245
db: db,
231-
path: cfg.StorageConfig.Dir,
232-
attrs: cfg.StorageConfig.Attrs,
233-
settings: cfg.StorageConfig.Settings,
246+
path: cfg.Dir,
247+
maxSize: cfg.MaxSize,
248+
attrs: cfg.Attrs,
249+
settings: cfg.Settings,
234250
fs: cfg.Opts.FS,
235251
}, nil
236252
}
@@ -389,9 +405,7 @@ func (p *Pebble) Attrs() roachpb.Attributes {
389405

390406
// Capacity implements the Engine interface.
391407
func (p *Pebble) Capacity() (roachpb.StoreCapacity, error) {
392-
// Pebble doesn't have a capacity limiting parameter, so pass 0 for
393-
// maxSizeBytes to denote no limit.
394-
return computeCapacity(p.path, 0)
408+
return computeCapacity(p.path, p.maxSize)
395409
}
396410

397411
// Flush implements the Engine interface.

0 commit comments

Comments
 (0)