diff --git a/cmd/influxd/run/server_suite_test.go b/cmd/influxd/run/server_suite_test.go index f0b962de42..ef39065a85 100644 --- a/cmd/influxd/run/server_suite_test.go +++ b/cmd/influxd/run/server_suite_test.go @@ -340,11 +340,6 @@ func init() { command: `SHOW RETENTION POLICIES ON db0`, exp: `{"results":[{"series":[{"columns":["name","duration","replicaN","default"],"values":[["rp0","2h0m0s",3,true]]}]}]}`, }, - &Query{ - name: "dropping default retention policy should not succeed", - command: `DROP RETENTION POLICY rp0 ON db0`, - exp: `{"results":[{"error":"retention policy is default"}]}`, - }, &Query{ name: "show retention policy should still show policy", command: `SHOW RETENTION POLICIES ON db0`, diff --git a/cmd/influxd/run/server_test.go b/cmd/influxd/run/server_test.go index 3e47fa1a43..ff024d53ac 100644 --- a/cmd/influxd/run/server_test.go +++ b/cmd/influxd/run/server_test.go @@ -4285,7 +4285,7 @@ func TestServer_Query_Where_With_Tags(t *testing.T) { name: "where on tag that should be double quoted but isn't", params: url.Values{"db": []string{"db0"}}, command: `show series where data-center = 'foo'`, - exp: `{"results":[{"error":"invalid expression: data - center = 'foo'"}]}`, + exp: `{"error":"error parsing query: found DATA, expected identifier, string, number, bool at line 1, char 19"}`, }, }...) diff --git a/services/meta/client.go b/services/meta/client.go index 42358a4edc..0ad3eb1b94 100644 --- a/services/meta/client.go +++ b/services/meta/client.go @@ -101,6 +101,12 @@ func (c *Client) Close() error { return nil } +func (c *Client) Data() *Data { + c.mu.RLock() + defer c.mu.RUnlock() + return c.data +} + // ClusterID returns the ID of the cluster it's connected to. func (c *Client) ClusterID() uint64 { c.mu.RLock() @@ -314,7 +320,32 @@ func (c *Client) SetDefaultRetentionPolicy(database, name string) error { // UpdateRetentionPolicy updates a retention policy. func (c *Client) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error { - return nil + var newName *string + if rpu.Name != nil { + newName = rpu.Name + } + + var duration *int64 + if rpu.Duration != nil { + value := int64(*rpu.Duration) + duration = &value + } + + var replicaN *uint32 + if rpu.ReplicaN != nil { + value := uint32(*rpu.ReplicaN) + replicaN = &value + } + + cmd := &internal.UpdateRetentionPolicyCommand{ + Database: proto.String(database), + Name: proto.String(name), + NewName: newName, + Duration: duration, + ReplicaN: replicaN, + } + + return c.retryUntilExec(internal.Command_UpdateRetentionPolicyCommand, internal.E_UpdateRetentionPolicyCommand_Command, cmd) } // IsLeader - should get rid of this @@ -557,6 +588,10 @@ func (c *Client) ShardGroupsByTimeRange(database, policy string, min, max time.T // CreateShardGroup creates a shard group on a database and policy for a given timestamp. func (c *Client) CreateShardGroup(database, policy string, timestamp time.Time) (*ShardGroupInfo, error) { + if sg, _ := c.Data().ShardGroupByTimestamp(database, policy, timestamp); sg != nil { + return sg, nil + } + cmd := &internal.CreateShardGroupCommand{ Database: proto.String(database), Policy: proto.String(policy), @@ -864,7 +899,7 @@ func (c *Client) exec(url string, typ internal.Command_Type, desc *proto.Extensi if resp.StatusCode == http.StatusTemporaryRedirect { return 0, errRedirect{host: resp.Header.Get("Location")} } else if resp.StatusCode != http.StatusOK { - return 0, fmt.Errorf("unexpected result:\n\texp: %d\n\tgot: %d\n", http.StatusOK, resp.StatusCode) + return 0, fmt.Errorf("meta service returned %s", resp.Status) } res := &internal.Response{} @@ -879,7 +914,7 @@ func (c *Client) exec(url string, typ internal.Command_Type, desc *proto.Extensi } es := res.GetError() if es != "" { - return 0, fmt.Errorf("exec err: %s", es) + return 0, fmt.Errorf(es) } return res.GetIndex(), nil diff --git a/services/meta/data.go b/services/meta/data.go index bbb344009a..b11db97d28 100644 --- a/services/meta/data.go +++ b/services/meta/data.go @@ -438,7 +438,7 @@ func (data *Data) CreateShardGroup(database, policy string, timestamp time.Time) // Verify that shard group doesn't already exist for this timestamp. if rpi.ShardGroupByTimestamp(timestamp) != nil { - return ErrShardGroupExists + return nil } // Require at least one replica but no more replicas than nodes.