Skip to content

check for retention period to be a multiple of periodic table duration and relevant test #1564

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

Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## master / unreleased

* [CHANGE] Retention period should now be a multiple of periodic table duration #1564
* [FEATURE] Add option to use jump hashing to load balance requests to memcached #1554
* [FEATURE] Add status page for HA tracker to distributors #1546

Expand Down
10 changes: 10 additions & 0 deletions pkg/chunk/table_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package chunk

import (
"context"
"errors"
"flag"
"fmt"
"sort"
Expand Down Expand Up @@ -126,6 +127,15 @@ type TableManager struct {
// NewTableManager makes a new TableManager
func NewTableManager(cfg TableManagerConfig, schemaCfg SchemaConfig, maxChunkAge time.Duration, tableClient TableClient,
objectClient BucketClient) (*TableManager, error) {

if cfg.RetentionPeriod != 0 {
// Assume the newest config is the one to use for validation of retention
indexTablesPeriod := schemaCfg.Configs[len(schemaCfg.Configs)-1].IndexTables.Period
if indexTablesPeriod != 0 && cfg.RetentionPeriod%indexTablesPeriod != 0 {
return nil, errors.New("retention period should now be a multiple of periodic table duration")
}
}

return &TableManager{
cfg: cfg,
schemaCfg: schemaCfg,
Expand Down
5 changes: 5 additions & 0 deletions pkg/chunk/table_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,4 +691,9 @@ func TestTableManagerRetentionOnly(t *testing.T) {
{Name: chunkTablePrefix + "3", ProvisionedRead: read, ProvisionedWrite: write},
},
)

// Test table manager retention not multiple of periodic config
tbmConfig.RetentionPeriod++
_, err = NewTableManager(tbmConfig, cfg, maxChunkAge, client, nil)
require.Error(t, err)
}