Skip to content

Commit

Permalink
Don't automatically create shards
Browse files Browse the repository at this point in the history
This was causing InfluxDB to create a new shard in the grafana db every
ten minutes. Also we talked about getting rid of this feature a while
ago, so here we go.

Fix #954

Conflicts:
	cluster/cluster_configuration.go
  • Loading branch information
jvshahid committed Sep 24, 2014
1 parent 020dd3c commit 1ff8ba4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 31 deletions.
30 changes: 0 additions & 30 deletions cluster/cluster_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,6 @@ func (self *ClusterConfiguration) GetShardSpaces() []*ShardSpace {
return spaces
}

// called by the server, this will wake up every 10 mintues to see if it should
// create a shard for the next window of time. This way shards get created before
// a bunch of writes stream in and try to create it all at the same time.
func (self *ClusterConfiguration) CreateFutureShardsAutomaticallyBeforeTimeComes() {
go func() {
for {
time.Sleep(time.Minute * 10)
log.Debug("Checking to see if future shards should be created")
spaces := self.allSpaces()
for _, s := range spaces {
self.automaticallyCreateFutureShard(s)
}
}
}()
}

func (self *ClusterConfiguration) allSpaces() []*ShardSpace {
self.shardLock.RLock()
defer self.shardLock.RUnlock()
Expand Down Expand Up @@ -205,20 +189,6 @@ func (self *ClusterConfiguration) GetExpiredShards() []*ShardData {
return shards
}

func (self *ClusterConfiguration) automaticallyCreateFutureShard(shardSpace *ShardSpace) {
if len(shardSpace.shards) == 0 {
// don't automatically create shards if they haven't created any yet.
return
}
latestShard := shardSpace.shards[0]
if latestShard.endTime.Add(-15*time.Minute).Unix() < time.Now().Unix() {
newShardTime := latestShard.endTime.Add(time.Second)
microSecondEpochForNewShard := newShardTime.Unix() * 1000 * 1000
log.Info("Automatically creating shard for %s", newShardTime.Format("Mon Jan 2 15:04:05 -0700 MST 2006"))
self.createShards(microSecondEpochForNewShard, shardSpace)
}
}

func (self *ClusterConfiguration) ServerId() uint32 {
return self.LocalServer.Id
}
Expand Down
1 change: 0 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func NewServer(config *configuration.Configuration) (*Server, error) {
metaStore.SetClusterConsensus(raftServer)
clusterConfig.LocalRaftName = raftServer.GetRaftName()
clusterConfig.SetShardCreator(raftServer)
clusterConfig.CreateFutureShardsAutomaticallyBeforeTimeComes()

coord := coordinator.NewCoordinatorImpl(config, raftServer, clusterConfig, metaStore)
requestHandler := coordinator.NewProtobufRequestHandler(coord, clusterConfig)
Expand Down

0 comments on commit 1ff8ba4

Please sign in to comment.