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] Set default cache on retrieve to false, prepare testing with cache none #2813

Merged
merged 5 commits into from
Oct 28, 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
2 changes: 1 addition & 1 deletion src/dbnode/namespace/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func assertEqualMetadata(t *testing.T, name string, expected nsproto.NamespaceOp
require.Equal(t, name, observed.ID().String())
opts := observed.Options()

expectedCacheBlocksOnRetrieve := true
expectedCacheBlocksOnRetrieve := false
if expected.CacheBlocksOnRetrieve != nil {
expectedCacheBlocksOnRetrieve = expected.CacheBlocksOnRetrieve.Value
}
Expand Down
4 changes: 2 additions & 2 deletions src/dbnode/namespace/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const (
// Namespace with cold writes disabled by default.
defaultColdWritesEnabled = false

// Namespace caches retrieved blocks by default.
defaultCacheBlocksOnRetrieve = true
// Namespace does not cache retrieved blocks by default.
defaultCacheBlocksOnRetrieve = false
)

var (
Expand Down
2 changes: 2 additions & 0 deletions src/dbnode/persist/fs/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ var (
testNs2ID = ident.StringID("testNs2")
testNs1Metadata = func(t *testing.T) namespace.Metadata {
md, err := namespace.NewMetadata(testNs1ID, namespace.NewOptions().
SetCacheBlocksOnRetrieve(true).
SetRetentionOptions(retention.NewOptions().SetBlockSize(testBlockSize)).
SetIndexOptions(namespace.NewIndexOptions().SetEnabled(true).SetBlockSize(testBlockSize)))
require.NoError(t, err)
return md
}
testNs2Metadata = func(t *testing.T) namespace.Metadata {
md, err := namespace.NewMetadata(testNs2ID, namespace.NewOptions().
SetCacheBlocksOnRetrieve(true).
SetRetentionOptions(retention.NewOptions().SetBlockSize(testBlockSize)).
SetIndexOptions(namespace.NewIndexOptions().SetEnabled(true).SetBlockSize(testBlockSize)))
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion src/dbnode/persist/fs/retriever_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
var (
// Allow max concurrency to match available CPUs.
defaultFetchConcurrency = runtime.NumCPU()
defaultCacheOnRetrieve = true
defaultCacheOnRetrieve = false

errBlockLeaseManagerNotSet = errors.New("block lease manager is not set")
)
Expand Down
2 changes: 2 additions & 0 deletions src/dbnode/persist/fs/seek_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const (
var (
defaultTestBlockRetrieverOptions = NewBlockRetrieverOptions().
SetBlockLeaseManager(&block.NoopLeaseManager{}).
// Test with caching enabled.
SetCacheBlocksOnRetrieve(true).
// Default value is determined by available CPUs, but for testing
// we want to have this been consistent across hardware.
SetFetchConcurrency(defaultTestingFetchConcurrency)
Expand Down
5 changes: 2 additions & 3 deletions src/dbnode/storage/bootstrap/bootstrapper/peers/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (s *peersSource) readData(
)

if persistConfig.Enabled &&
(seriesCachePolicy == series.CacheRecentlyRead || seriesCachePolicy == series.CacheLRU) &&
seriesCachePolicy != series.CacheAll &&
persistConfig.FileSetType == persist.FileSetFlushType {
shouldPersist = true
}
Expand Down Expand Up @@ -534,8 +534,7 @@ func (s *peersSource) flush(
}

seriesCachePolicy := s.opts.ResultOptions().SeriesCachePolicy()
if seriesCachePolicy != series.CacheRecentlyRead &&
seriesCachePolicy != series.CacheLRU {
if seriesCachePolicy == series.CacheAll {
// Should never happen.
iOpts := s.opts.ResultOptions().InstrumentOptions()
instrument.EmitAndLogInvariantViolation(iOpts, func(l *zap.Logger) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func TestPeersSourceReturnsUnfulfilled(t *testing.T) {

func TestPeersSourceRunWithPersist(t *testing.T) {
for _, cachePolicy := range []series.CachePolicy{
series.CacheNone,
series.CacheRecentlyRead,
series.CacheLRU,
} {
Expand Down
19 changes: 9 additions & 10 deletions src/query/api/v1/handler/database/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ import (
"testing"
"time"

"github.com/m3db/m3/src/cluster/kv/fake"

"github.com/m3db/m3/src/cluster/client"
"github.com/m3db/m3/src/cluster/generated/proto/placementpb"
"github.com/m3db/m3/src/cluster/kv"
"github.com/m3db/m3/src/cluster/kv/fake"
"github.com/m3db/m3/src/cluster/placement"
"github.com/m3db/m3/src/cluster/services"
dbconfig "github.com/m3db/m3/src/cmd/services/m3dbnode/config"
Expand Down Expand Up @@ -162,7 +161,7 @@ func testLocalType(t *testing.T, providedType string, placementExists bool) {
]
},
"bootstrapEnabled": true,
"cacheBlocksOnRetrieve": true,
"cacheBlocksOnRetrieve": false,
"flushEnabled": true,
"writesToCommitLog": true,
"cleanupEnabled": true,
Expand Down Expand Up @@ -338,7 +337,7 @@ func TestLocalTypeWithNumShards(t *testing.T) {
]
},
"bootstrapEnabled": true,
"cacheBlocksOnRetrieve": true,
"cacheBlocksOnRetrieve": false,
"flushEnabled": true,
"writesToCommitLog": true,
"cleanupEnabled": true,
Expand Down Expand Up @@ -467,7 +466,7 @@ func TestLocalWithBlockSizeNanos(t *testing.T) {
]
},
"bootstrapEnabled": true,
"cacheBlocksOnRetrieve": true,
"cacheBlocksOnRetrieve": false,
"flushEnabled": true,
"writesToCommitLog": true,
"cleanupEnabled": true,
Expand Down Expand Up @@ -601,7 +600,7 @@ func TestLocalWithBlockSizeExpectedSeriesDatapointsPerHour(t *testing.T) {
]
},
"bootstrapEnabled": true,
"cacheBlocksOnRetrieve": true,
"cacheBlocksOnRetrieve": false,
"flushEnabled": true,
"writesToCommitLog": true,
"cleanupEnabled": true,
Expand Down Expand Up @@ -865,7 +864,7 @@ func testClusterTypeHosts(t *testing.T, placementExists bool) {
]
},
"bootstrapEnabled": true,
"cacheBlocksOnRetrieve": true,
"cacheBlocksOnRetrieve": false,
"flushEnabled": true,
"writesToCommitLog": true,
"cleanupEnabled": true,
Expand Down Expand Up @@ -1022,7 +1021,7 @@ func TestClusterTypeHostsWithIsolationGroup(t *testing.T) {
]
},
"bootstrapEnabled": true,
"cacheBlocksOnRetrieve": true,
"cacheBlocksOnRetrieve": false,
"flushEnabled": true,
"writesToCommitLog": true,
"cleanupEnabled": true,
Expand Down Expand Up @@ -1239,7 +1238,7 @@ func TestLocalTypeWithAggregatedNamespace(t *testing.T) {
]
},
"bootstrapEnabled": true,
"cacheBlocksOnRetrieve": true,
"cacheBlocksOnRetrieve": false,
"flushEnabled": true,
"writesToCommitLog": true,
"cleanupEnabled": true,
Expand Down Expand Up @@ -1281,7 +1280,7 @@ func TestLocalTypeWithAggregatedNamespace(t *testing.T) {
]
},
"bootstrapEnabled": true,
"cacheBlocksOnRetrieve": true,
"cacheBlocksOnRetrieve": false,
"flushEnabled": true,
"writesToCommitLog": true,
"cleanupEnabled": true,
Expand Down
2 changes: 1 addition & 1 deletion src/query/api/v1/handler/namespace/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestNamespaceAddHandler(t *testing.T) {
"testNamespace": xjson.Map{
"aggregationOptions": nil,
"bootstrapEnabled": true,
"cacheBlocksOnRetrieve": true,
"cacheBlocksOnRetrieve": false,
"flushEnabled": true,
"writesToCommitLog": true,
"cleanupEnabled": true,
Expand Down