Merge pull request #2852 from influxdb/panic_change_rp

Don't panic when altering retention policy
pull/2805/merge
Philip O'Toole 2015-06-09 14:16:11 -07:00
commit 6ce7c6e4ad
3 changed files with 14 additions and 3 deletions

View File

@ -8,6 +8,7 @@
- [2838](https://github.com/influxdb/influxdb/pull/2838) -- Set auto-created retention policy period to infinite.
- [2829](https://github.com/influxdb/influxdb/pull/2829) -- Re-enable Graphite support as a new Service-style component.
- [2814](https://github.com/influxdb/influxdb/issues/2814) -- Convert collectd to a service.
- [2852](https://github.com/influxdb/influxdb/pull/2852) -- Don't panic when altering retention policies. Thanks for the report @huhongbo
## v0.9.0-rc32 [2015-06-07]

View File

@ -367,9 +367,9 @@ func TestStatementExecutor_ExecuteStatement_AlterRetentionPolicy(t *testing.T) {
t.Fatalf("unexpected database: %s", database)
} else if name != "rp0" {
t.Fatalf("unexpected name: %s", name)
} else if *rpu.Duration != 7*24*time.Hour {
} else if rpu.Duration != nil && *rpu.Duration != 7*24*time.Hour {
t.Fatalf("unexpected duration: %v", *rpu.Duration)
} else if *rpu.ReplicaN != 2 {
} else if rpu.ReplicaN != nil && *rpu.ReplicaN != 2 {
t.Fatalf("unexpected replication factor: %v", *rpu.ReplicaN)
}
return nil
@ -387,6 +387,16 @@ func TestStatementExecutor_ExecuteStatement_AlterRetentionPolicy(t *testing.T) {
if res := e.ExecuteStatement(stmt); res.Err != nil {
t.Fatalf("unexpected error: %s", res.Err)
}
stmt = influxql.MustParseStatement(`ALTER RETENTION POLICY rp0 ON foo DURATION 7d`)
if res := e.ExecuteStatement(stmt); res.Err != nil {
t.Fatalf("unexpected error: %s", res.Err)
}
stmt = influxql.MustParseStatement(`ALTER RETENTION POLICY rp0 ON foo REPLICATION 2`)
if res := e.ExecuteStatement(stmt); res.Err != nil {
t.Fatalf("unexpected error: %s", res.Err)
}
}
// Ensure a ALTER RETENTION POLICY statement returns errors from the store.

View File

@ -719,7 +719,7 @@ func (s *Store) UpdateRetentionPolicy(database, name string, rpu *RetentionPolic
}
var replicaN *uint32
if rpu.Duration != nil {
if rpu.ReplicaN != nil {
value := uint32(*rpu.ReplicaN)
replicaN = &value
}