Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dbnode] Make caching after block retrieval a configuration option #2613

Merged
merged 4 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/cmd/services/m3dbnode/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ type BlockRetrievePolicy struct {
// FetchConcurrency is the concurrency to fetch blocks from disk. For
// spinning disks it is highly recommended to set this value to 1.
FetchConcurrency int `yaml:"fetchConcurrency" validate:"min=0"`

// CacheBlocksOnRetrieve globally enables/disables callbacks used to cache blocks fetched
// from disk.
CacheBlocksOnRetrieve *bool `yaml:"cacheBlocksOnRetrieve"`
}

// CommitLogPolicy is the commit log policy.
Expand Down
19 changes: 11 additions & 8 deletions src/cmd/tools/dtest/docker/harness/resources/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import (
"github.com/m3db/m3/src/query/generated/proto/admin"
xerrors "github.com/m3db/m3/src/x/errors"
"github.com/m3db/m3/src/x/instrument"
dockertest "github.com/ory/dockertest"

protobuftypes "github.com/gogo/protobuf/types"
"github.com/ory/dockertest"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -150,13 +152,14 @@ func SetupSingleM3DBNode() (DockerResources, error) {
coldWriteNamespace = admin.NamespaceAddRequest{
Name: ColdWriteNsName,
Options: &namespace.NamespaceOptions{
BootstrapEnabled: true,
FlushEnabled: true,
WritesToCommitLog: true,
CleanupEnabled: true,
SnapshotEnabled: true,
RepairEnabled: true,
ColdWritesEnabled: true,
BootstrapEnabled: true,
FlushEnabled: true,
WritesToCommitLog: true,
CleanupEnabled: true,
SnapshotEnabled: true,
RepairEnabled: true,
ColdWritesEnabled: true,
CacheBlocksOnRetrieve: &protobuftypes.BoolValue{Value: true},
RetentionOptions: &namespace.RetentionOptions{
RetentionPeriodNanos: int64(4 * time.Hour),
BlockSizeNanos: int64(time.Hour),
Expand Down
179 changes: 118 additions & 61 deletions src/dbnode/generated/proto/namespace/namespace.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions src/dbnode/generated/proto/namespace/namespace.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ message IndexOptions {
}

message NamespaceOptions {
bool bootstrapEnabled = 1;
bool flushEnabled = 2;
bool writesToCommitLog = 3;
bool cleanupEnabled = 4;
bool repairEnabled = 5;
RetentionOptions retentionOptions = 6;
bool snapshotEnabled = 7;
IndexOptions indexOptions = 8;
SchemaOptions schemaOptions = 9;
bool coldWritesEnabled = 10;
NamespaceRuntimeOptions runtimeOptions = 11;
bool bootstrapEnabled = 1;
bool flushEnabled = 2;
bool writesToCommitLog = 3;
bool cleanupEnabled = 4;
bool repairEnabled = 5;
RetentionOptions retentionOptions = 6;
bool snapshotEnabled = 7;
IndexOptions indexOptions = 8;
SchemaOptions schemaOptions = 9;
bool coldWritesEnabled = 10;
NamespaceRuntimeOptions runtimeOptions = 11;
google.protobuf.BoolValue cacheBlocksOnRetrieve = 12;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using google.protobuf.BoolValue to support backwards compatibility with namespace definitions already in etcd. A null value here allows us to correctly default to enabled.

}

message Registry {
Expand Down
22 changes: 13 additions & 9 deletions src/dbnode/namespace/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ func (m *MapConfiguration) Map() (Map, error) {

// MetadataConfiguration is the configuration for a single namespace
type MetadataConfiguration struct {
ID string `yaml:"id" validate:"nonzero"`
BootstrapEnabled *bool `yaml:"bootstrapEnabled"`
FlushEnabled *bool `yaml:"flushEnabled"`
WritesToCommitLog *bool `yaml:"writesToCommitLog"`
CleanupEnabled *bool `yaml:"cleanupEnabled"`
RepairEnabled *bool `yaml:"repairEnabled"`
ColdWritesEnabled *bool `yaml:"coldWritesEnabled"`
Retention retention.Configuration `yaml:"retention" validate:"nonzero"`
Index IndexConfiguration `yaml:"index"`
ID string `yaml:"id" validate:"nonzero"`
BootstrapEnabled *bool `yaml:"bootstrapEnabled"`
FlushEnabled *bool `yaml:"flushEnabled"`
WritesToCommitLog *bool `yaml:"writesToCommitLog"`
CleanupEnabled *bool `yaml:"cleanupEnabled"`
RepairEnabled *bool `yaml:"repairEnabled"`
ColdWritesEnabled *bool `yaml:"coldWritesEnabled"`
CacheBlocksOnRetrieve *bool `yaml:"cacheBlocksOnRetrieve"`
Retention retention.Configuration `yaml:"retention" validate:"nonzero"`
Index IndexConfiguration `yaml:"index"`
}

// Metadata returns a Metadata corresponding to the receiver struct
Expand Down Expand Up @@ -84,6 +85,9 @@ func (mc *MetadataConfiguration) Metadata() (Metadata, error) {
if v := mc.ColdWritesEnabled; v != nil {
opts = opts.SetColdWritesEnabled(*v)
}
if v := mc.CacheBlocksOnRetrieve; v != nil {
opts = opts.SetCacheBlocksOnRetrieve(*v)
}
return NewMetadata(ident.StringID(mc.ID), opts)
}

Expand Down
Loading