Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update retention policy before saving database #1564

Merged
merged 3 commits into from
Feb 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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