Merge pull request #2060 from influxdb/reload_sharp_map

Reload shard map on restart
pull/2053/head^2
Philip O'Toole 2015-03-24 12:25:08 -07:00
commit 9f723d6a24
2 changed files with 13 additions and 1 deletions

View File

@ -11,6 +11,7 @@
- [#2034](https://github.com/influxdb/influxdb/pull/2034): GROUP BY should require an aggregate.
- [#2040](https://github.com/influxdb/influxdb/pull/2040): Add missing top-level help for config command.
- [#2057](https://github.com/influxdb/influxdb/pull/2057): Move racy "in order" test to integration test suite.
- [#2060](https://github.com/influxdb/influxdb/pull/2060): Reload server shard map on restart.
## v0.9.0-rc15 [2015-03-19]

View File

@ -264,6 +264,12 @@ func (s *Server) close() error {
_ = sh.close()
}
// Server is closing, empty maps which should be reloaded on open.
s.shards = nil
s.dataNodes = nil
s.databases = nil
s.users = nil
return nil
}
@ -296,11 +302,16 @@ func (s *Server) load() error {
}
}
// Open all shards owned by server.
// Load shards.
s.shards = make(map[uint64]*Shard)
for _, db := range s.databases {
for _, rp := range db.policies {
for _, g := range rp.shardGroups {
for _, sh := range g.Shards {
// Add to lookups.
s.shards[sh.ID] = sh
// Only open shards owned by the server.
if !sh.HasDataNodeID(s.id) {
continue
}