Skip to content

Commit ab50f94

Browse files
sandeepsukhanigouthamve
authored andcommitted
check for retention period to be a multiple of periodic table duration and relevant test (#1564)
* added check for retention period to be a multiple of periodic table duration and relevant test Signed-off-by: Sandeep Sukhani <[email protected]> * updated changelog Signed-off-by: Sandeep Sukhani <[email protected]> * check for periodic table duration not 0 Signed-off-by: Sandeep Sukhani <[email protected]> * moved update in changelog above features Signed-off-by: Sandeep Sukhani <[email protected]>
1 parent 1c57ecb commit ab50f94

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## master / unreleased
22

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

pkg/chunk/table_manager.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package chunk
22

33
import (
44
"context"
5+
"errors"
56
"flag"
67
"fmt"
78
"sort"
@@ -126,6 +127,15 @@ type TableManager struct {
126127
// NewTableManager makes a new TableManager
127128
func NewTableManager(cfg TableManagerConfig, schemaCfg SchemaConfig, maxChunkAge time.Duration, tableClient TableClient,
128129
objectClient BucketClient) (*TableManager, error) {
130+
131+
if cfg.RetentionPeriod != 0 {
132+
// Assume the newest config is the one to use for validation of retention
133+
indexTablesPeriod := schemaCfg.Configs[len(schemaCfg.Configs)-1].IndexTables.Period
134+
if indexTablesPeriod != 0 && cfg.RetentionPeriod%indexTablesPeriod != 0 {
135+
return nil, errors.New("retention period should now be a multiple of periodic table duration")
136+
}
137+
}
138+
129139
return &TableManager{
130140
cfg: cfg,
131141
schemaCfg: schemaCfg,

pkg/chunk/table_manager_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,4 +691,9 @@ func TestTableManagerRetentionOnly(t *testing.T) {
691691
{Name: chunkTablePrefix + "3", ProvisionedRead: read, ProvisionedWrite: write},
692692
},
693693
)
694+
695+
// Test table manager retention not multiple of periodic config
696+
tbmConfig.RetentionPeriod++
697+
_, err = NewTableManager(tbmConfig, cfg, maxChunkAge, client, nil)
698+
require.Error(t, err)
694699
}

0 commit comments

Comments
 (0)