Skip to content

Commit

Permalink
Merge pull request #1564 from influxdb/persist_policies
Browse files Browse the repository at this point in the history
Update retention policy before saving database
  • Loading branch information
otoolep committed Feb 11, 2015
2 parents 40c211a + e417852 commit beefdee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ func (s *Server) Close() error {
// Close metastore.
_ = s.meta.close()

// Close shards.
for _, sh := range s.shards {
_ = sh.close()
}

return nil
}

Expand Down Expand Up @@ -834,6 +839,9 @@ func (s *Server) applyCreateShardGroupIfNotExists(m *messaging.Message) (err err
}
}

// Retention policy has a new shard group, so update the policy.
rp.shardGroups = append(rp.shardGroups, g)

return tx.saveDatabase(db)
}); err != nil {
g.close()
Expand All @@ -857,7 +865,6 @@ func (s *Server) applyCreateShardGroupIfNotExists(m *messaging.Message) (err err
for _, sh := range g.Shards {
s.shards[sh.ID] = sh
}
rp.shardGroups = append(rp.shardGroups, g)

// Subscribe to shard if it matches the server's index.
// TODO: Move subscription outside of command processing.
Expand Down
3 changes: 3 additions & 0 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,9 @@ func TestServer_CreateShardGroupIfNotExist(t *testing.T) {
t.Fatal(err)
}

// Restart the server to ensure the shard group is not lost.
s.Restart()

if a, err := s.ShardGroups("foo"); err != nil {
t.Fatal(err)
} else if len(a) != 1 {
Expand Down

0 comments on commit beefdee

Please sign in to comment.