Skip to content

Commit

Permalink
Merge pull request #3030 from influxdb/better_sg_logging
Browse files Browse the repository at this point in the history
Fix excessive shard group creation logging
  • Loading branch information
otoolep committed Jun 17, 2015
2 parents 2428edb + 0c1d256 commit c9906d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [#3002](https://github.com/influxdb/influxdb/pull/3002): Remove measurement from shard's index on DROP MEASUREMENT.
- [#3021](https://github.com/influxdb/influxdb/pull/3021): Correct set HTTP write trace logging. Thanks @vladlopes.
- [#3027](https://github.com/influxdb/influxdb/pull/3027): Enforce minimum retention policy duration of 1 hour.
- [#3030](https://github.com/influxdb/influxdb/pull/3030): Fix excessive logging of shard creation.

## v0.9.0 [2015-06-11]

Expand Down
19 changes: 15 additions & 4 deletions meta/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,13 +1071,24 @@ func (s *Store) PrecreateShardGroups(cutoff time.Time) error {
for _, g := range rp.ShardGroups {
// Check to see if it is going to end before our interval
if g.EndTime.Before(cutoff) {
s.Logger.Printf("pre-creating successive shard group for group %d, database %s, policy %s",
g.ID, di.Name, rp.Name)
if newGroup, err := s.CreateShardGroupIfNotExists(di.Name, rp.Name, g.EndTime.Add(1*time.Nanosecond)); err != nil {
nextShardGroupTime := g.EndTime.Add(1 * time.Nanosecond)

// Check if successive shard group exists.
if sgi, err := s.ShardGroupByTimestamp(di.Name, rp.Name, nextShardGroupTime); err != nil {
s.Logger.Printf("failed to check if successive shard group for group exists %d: %s",
g.ID, err.Error())
continue
} else if sgi != nil && !sgi.Deleted() {
continue
}

// It doesn't. Create it.
if newGroup, err := s.CreateShardGroupIfNotExists(di.Name, rp.Name, nextShardGroupTime); err != nil {
s.Logger.Printf("failed to create successive shard group for group %d: %s",
g.ID, err.Error())
} else {
s.Logger.Printf("new shard group %d successfully created", newGroup.ID)
s.Logger.Printf("new shard group %d successfully created for database %s, retention policy %s",
newGroup.ID, di.Name, rp.Name)
}
}
}
Expand Down

0 comments on commit c9906d8

Please sign in to comment.