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

Tag TSM stats with database and retention policy #5844

Merged
merged 1 commit into from
Feb 29, 2016

Conversation

mark-rushakoff
Copy link
Contributor

(This probably should have been part of #5810. Hindsight is 20/20.)

The primary intent of this changeset is to tag stats for TSM cache, WAL, and filestore with the owner database and retention policy. The database and retention policy are inferred from the path supplied to the engine component.

@@ -112,11 +113,15 @@ type Cache struct {

// NewCache returns an instance of a cache which will use a maximum of maxSize bytes of memory.
// Only used for engine caches, never for snapshots
func NewCache(maxSize uint64, path string) *Cache {
func NewCache(maxSize uint64, config tsdb.ShardConfig) *Cache {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be confusing to pass in the shard config to this function since only one of the two attributes included in the shard config are actually used. When using this function, you may wonder "why does it only care about one part of the config?"

I think it might be better to continue passing the path as a string directly here and to modify the call site in NewEngine to pass in the relevant string from the shard config. It will also make the diff a lot smaller and won't change the public interface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree w/ @jsternberg. I prefer that path args.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shard config contains 4 fields:

  • Path, which was previously used in NewCache
  • WALPath, which is ignored in NewCache
  • Database and RetentionPolicy, which are now used as tags on the Cache (and Filestore and WAL) so that it's trivial to match up which Shards and which parts of the engine stats line up together

@jsternberg
Copy link
Contributor

I missed the part where the database and retention policy from the shard config were being used since I only saw how the tests were modified.

I retract my previous comments.

👍

@mark-rushakoff
Copy link
Contributor Author

After some out-of-band discussion, I'm going to amend the commit to continue passing path as before, but to introduce a function like DecodePath to identify the database and retention policy.

@mark-rushakoff
Copy link
Contributor Author

Rebased to address comments and now ready for re-review @jsternberg @jwilder.

path, _ := filepath.Split(filepath.Clean(shardOrWALPath))

// Extract the database and retention policy.
path, rp := filepath.Split(filepath.Clean(path))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably not necessary to call clean multiple times. Should you just use filepath.SplitList?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary. See golang/go#9928 for a slightly more detailed discussion.

filepath.SplitList is meant to parse out colon separated list of paths like you would see in your $PATH environment variable.

@jsternberg
Copy link
Contributor

👍

@jwilder
Copy link
Contributor

jwilder commented Feb 29, 2016

Needs a changelog entry, but 👍 after that.

statMap: statMap,
LogOutput: os.Stderr,
}
}

// Path returns the path set on the shard when it was created.
func (s *Shard) Path() string { return s.config.Path }
func (s *Shard) Path() string { return s.path }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this doesn't need a read lock on s.mu, I think it should either have one, or the one in DiskSize should be removed. There are no concurrent writes to s.path, so technically no lock is currently needed, but it would be better to be consistent either way..

If it's decided to add a read lock to Path() then you should also move path under mu in the Shard type definition.

@mark-rushakoff
Copy link
Contributor Author

I'll remove the read lock from DiskSize as @e-dard suggested, update the changelog, and merge on gren.

... by extracting the db/rp from the given path.

Now that the code has "standardized" on extracting db/rp this way, the
ShardLocation struct is no longer necessary and thus has been removed.
We're back on the previous style of passing the path and walPath to
NewShard.
mark-rushakoff added a commit that referenced this pull request Feb 29, 2016
Tag TSM stats with database and retention policy
@mark-rushakoff mark-rushakoff merged commit 70fbc46 into master Feb 29, 2016
@mark-rushakoff mark-rushakoff deleted the mr-tsm-stats-tag-db-rp branch February 29, 2016 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants