Don't panic when altering retention policy

Fixes issue #2846
pull/2852/head
Philip O'Toole 2015-06-09 11:37:49 -07:00
parent 1f8eb9d8c0
commit 21343e4e0f
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. - [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. - [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. - [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] ## 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) t.Fatalf("unexpected database: %s", database)
} else if name != "rp0" { } else if name != "rp0" {
t.Fatalf("unexpected name: %s", name) 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) 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) t.Fatalf("unexpected replication factor: %v", *rpu.ReplicaN)
} }
return nil return nil
@ -387,6 +387,16 @@ func TestStatementExecutor_ExecuteStatement_AlterRetentionPolicy(t *testing.T) {
if res := e.ExecuteStatement(stmt); res.Err != nil { if res := e.ExecuteStatement(stmt); res.Err != nil {
t.Fatalf("unexpected error: %s", res.Err) 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. // 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 var replicaN *uint32
if rpu.Duration != nil { if rpu.ReplicaN != nil {
value := uint32(*rpu.ReplicaN) value := uint32(*rpu.ReplicaN)
replicaN = &value replicaN = &value
} }