Skip to content

Commit 4da3673

Browse files
added check for retention period to be a multiple of periodic table duration and relevant test
Signed-off-by: Sandeep Sukhani <[email protected]>
1 parent 1c57ecb commit 4da3673

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGELOG.md

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

33
* [FEATURE] Add option to use jump hashing to load balance requests to memcached #1554
44
* [FEATURE] Add status page for HA tracker to distributors #1546
5+
* [CHANGE] Added check for retention period to be a multiple of periodic table duration #1564
56

67
## 0.1.0 / 2019-08-07
78

@@ -13,3 +14,4 @@
1314
* [FEATURE] You can specify "heap ballast" to reduce Go GC Churn #1489
1415
* [BUGFIX] HA Tracker no longer always makes a request to Consul/Etcd when a request is not from the active replica #1516
1516
* [BUGFIX] Queries are now correctly cancelled by the query-frontend #1508
17+
* [CHANGE] Added check for retention period to be a multiple of periodic table duration

pkg/chunk/table_manager.go

Lines changed: 6 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,11 @@ 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+
// Assume the newest config is the one to use for validation of retention
131+
if cfg.RetentionPeriod != 0 && cfg.RetentionPeriod%schemaCfg.Configs[len(schemaCfg.Configs)-1].IndexTables.Period != 0 {
132+
return nil, errors.New("retention period should now be a multiple of periodic table duration")
133+
}
134+
129135
return &TableManager{
130136
cfg: cfg,
131137
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)