Commit Graph

1259 Commits (c6763fc0aec7fe6964c7a5ab3b690f4b0af58697)

Author SHA1 Message Date
Jason Wilder 8fda621d8b Fix memory spike when compacting overwritten points
If a large series contains a point that is overwritten, the compactor
would load the whole series into RAM during a full compaction.  If
the series was large, it could cause very large RAM spikes and OOMs.

The change reworks the compactor to merge blocks more incrementally
similar to the fix done in #6556.

Fixes #6557
2016-05-18 15:25:55 -06:00
Jason Wilder f1ab89561a Reload series count stat at startup 2016-05-18 15:21:57 -06:00
Edd Robinson 28ad7c687b Add const for interval 2016-05-18 22:14:59 +01:00
Jason Wilder cbc551f9dc Collect shard size stats 2016-05-18 22:14:59 +01:00
Jonathan A. Sternberg 946968ba23 Fixing panic in SHOW FIELD KEYS caused by 733a17d
The list of field keys in the index may have differed from the field
keys in the actual shard. Fixing `SHOW FIELD KEYS` so it relies only on
the shard rather than the index.

Fixes #6659.
2016-05-18 14:43:50 -04:00
Edd Robinson f78e67d09c Fix concurrent map access panic 2016-05-18 17:56:50 +01:00
Edd Robinson f680ab0f0d Fix vet issues 2016-05-18 13:34:11 +01:00
Joe LeGasse af432e7d12 Fix loop variable reuse in database close
Fixes #6650
2016-05-17 11:25:39 -04:00
Jonathan A. Sternberg 42cdaf0365 Merge pull request #6529 from influxdata/js-6519-select-tag-key-specifier
Support cast syntax for selecting a specific type
2016-05-16 12:30:14 -04:00
Jonathan A. Sternberg 23f6a706bb Support cast syntax for selecting a specific type
Casting syntax is done with the PostgreSQL syntax `field1::float` to
specify which type should be used when selecting a field. You can also
do `field1::field` or `tag1::tag` to specify that a field or tag should
be selected.

This makes it possible to select a tag when a field key and a tag key
conflict with each other in a measurement. It also means it's possible
to choose a field with a specific type if multiple shards disagree. If
no types are given, the same ordering for how a type is chosen is used
to determine which type to return.

The FieldDimensions method has been updated to return the data type for
the fields that get returned. The SeriesKeys function has also been
removed since it is no longer needed. SeriesKeys was originally used for
the fill iterator, but then expanded to be used by auxiliary iterators
for determining the channel iterator types. The fill iterator doesn't
need it anymore and the auxiliary types are better served by
FieldDimensions implementing that functionality, so SeriesKeys is no
longer needed.

Fixes #6519.
2016-05-16 12:08:29 -04:00
Jason Wilder ce141eae37 Merge pull request #6637 from influxdata/jw-revert-compact
Revert "Fix memory spike when compacting overwritten points"
2016-05-16 09:46:24 -06:00
Jason Wilder 23fc9ff748 Revert "Fix memory spike when compacting overwritten points"
This reverts commit d99c5e26f6.
2016-05-16 09:30:34 -06:00
Jonathan A. Sternberg a17f3d960a SHOW TAG VALUES accepts != and !~ in WHERE clause
Fixes #6607.
2016-05-16 08:51:09 -04:00
Jason Wilder 57d4becaec Fix possible deadlock when queries and delete series run concurrently
This locks showeed up in a deadlock systems running queries and
delete series across a large dataset.  Queries should not need to
lock the tsdb.Store for writes
2016-05-13 17:04:12 -06:00
Jason Wilder 5b6f3afefa Limit concurrent shards loading to number of cores available 2016-05-13 15:41:32 -06:00
Jason Wilder 11871958c6 Merge pull request #6618 from influxdata/jw-shard-load
Optimize shard index loading
2016-05-13 14:16:17 -06:00
Jason Wilder 9e54adc719 Speed up drop database
Drop database was closing and deleting each shard dir individually and
serially.  It would then delete the empty database dirs.

This changes drop database to close all shards in parallel and run
one os.RemoveAll to remove everything under the db dir which is more
efficient.

This also reworked the locking to avoid locking the tsdb.Store for
long periods of time.  That can cause queries and writes for other
databases to block as well.
2016-05-13 10:26:28 -06:00
Jason Wilder 0dbd4893da Optimize shard index loading
On data sets with many series and potentially large series keys,
the cost of parsing the key and re-indexing can be high.

Loading the TSM keys into the index was being done repeatedly for
series that were already index by an earlier TSM file.  This was
wasted worked and slows down shard loading.

Parsing the key was also innefficient and allocated a new string
slice.  This was simplified to remove that allocation.
2016-05-12 14:02:42 -06:00
Ben Johnson 7afb73aa99 Merge pull request #6598 from benbjohnson/parallelize-planning
Parallelize query planning
2016-05-12 09:00:58 -06:00
Jonathan A. Sternberg 89346bb618 Merge pull request #6600 from influxdata/0.13
Merge 0.13 release candidate back to master
2016-05-11 13:04:26 -04:00
Ben Johnson 668bae57df
parallelize query planning
This commit changes the `tsm1.Engine` to create individual series
iterators in batches so that it can be parallelized. Iterators
are combined at the end so they can be redistributed to the
parallelized merge iterator.
2016-05-11 10:38:11 -06:00
Cory LaNou c32906a366 Merge pull request #6593 from influxdata/cjl-copyshard
create shard snapshot
2016-05-10 20:01:59 -05:00
Jonathan A. Sternberg 8353b0c20f Merge pull request #6592 from influxdata/js-3451-show-field-keys-with-field-type
Update SHOW FIELD KEYS to return the field type with the field key
2016-05-10 14:13:17 -04:00
Jason Wilder d8490f1170 Merge pull request #6587 from influxdata/jw-validate-fields
Fix for merge values
2016-05-10 11:56:07 -06:00
Jonathan A. Sternberg 733a17d9e9 Update SHOW FIELD KEYS to return the field type with the field key
Fixes #3451.
2016-05-10 13:16:57 -04:00
Cory LaNou f415cf89ad wip 2016-05-10 11:01:03 -05:00
Jason Wilder 9b86bfea2a Merge pull request #6582 from eleme/fix_engine_cache_size
fix cache size of engine
2016-05-10 09:01:03 -06:00
Jason Wilder 8839cabd41 Add benchmark for Merge 2016-05-10 08:39:55 -06:00
Cory LaNou 4d30ea1eb3 minor PR feedback refactor 2016-05-10 08:14:51 -05:00
Cory LaNou a3bf3e2ef1 added baseline backup/restore plumbing 2016-05-10 08:14:51 -05:00
Jason Wilder 4f39cb2f97 Fix case where Merge return unsorted values 2016-05-09 15:40:34 -06:00
Ben Johnson 078e561820
parallelize iterators 2016-05-09 10:25:30 -06:00
Jonathan A. Sternberg 3f4072be7a Fix SHOW TAG VALUES condition to not filter "name" erroneously
Before #6038 was merged, we needed to filter "name" so that it didn't
accidentally hit the code path that used "name" to check the name of a
measurement. This was changed to "_name" to avoid a conflict with a
legitimate tag that used "name" as the key.

SHOW TAG VALUES was never modified to remove the code that filtered out
"name". This removes that line of code so a condition with "name"
doesn't get removed erroneously.

Example:

    SHOW TAG VALUES WITH KEY = host WHERE "name" = 'jsternberg'

Fixes #6581.
2016-05-09 10:27:53 -04:00
thbourlove 22c2e7e1c5 fix cache memory size of engine 2016-05-09 21:29:34 +08:00
Jason Wilder d99c5e26f6 Fix memory spike when compacting overwritten points
If a large series contains a point that is overwritten, the compactor
would load the whole series into RAM during a full compaction.  If
the series was large, it could cause very large RAM spikes and OOMs.

The change reworks the compactor to merge blocks more incrementally
similar to the fix done in #6556.
2016-05-05 22:31:30 -06:00
Ben Johnson 4c45f8ec32 Merge pull request #6560 from benbjohnson/optimize-tsm1-call-iterator
Move call iterator to series level
2016-05-05 11:13:53 -06:00
Ben Johnson fdf34d4356
move call iterator to series level
This commit moves the `CallIterator` to wrap the individual series
instead of wrapping a shard. This allows individual points to be
aggregated before being merged.

This will cause a small increase in memory usuage per series but
it shows a 20% decrease in query time when there are a moderate
number of points per series.
2016-05-05 09:59:03 -06:00
Jason Wilder a0ac754802 Fix loading huge series into RAM when points are overwritten
In some query scenarios, if there are a lot of points on disk spread
across many blocks in TSM files and a point is overwritten near the
begginning of the shard's timerange, the full series could be loaded
into RAM triggering OOMs and huge allocations.

The issue was that the KeyCursor code that handles overwriting points
had a simple implementation that just deduped the whole series in this
case.  This falls over when the series is quite large.

Instead, the KeyCursor has been changed to only decode blocks with
updated points.  It then keeps track of what section of the blocks
have been read so they are not re-read when the later points are
decoded.

Since the points in a block are always sorted, the code was also changed
to remove the Deduplicate calls since they end up
reallocating the slice.  Instead, we do a sorted merge and re-use
the slice as much as we can.
2016-05-05 09:34:44 -06:00
Jason Wilder 57cb3fdbc0 Merge pull request #6522 from influxdata/tp-tsm-dump
Dump TSM files to line protocol
2016-05-03 10:44:33 -06:00
Jason Wilder 4196554f51 Fix overwriting points returning wrong value
The cursors were returning the wrong value in the case when points
existed in both the cache and tsm files with the same timestamp. The
cache value should have been returned, but the tsm value was returned
incorrectly.

Fixes #6439
2016-05-03 09:21:31 -06:00
Ben Johnson 417df18396 Merge pull request #6533 from benbjohnson/optimize-show-series
Optimize SHOW SERIES
2016-05-03 09:15:21 -06:00
Edd Robinson fd77dbe648 Merge pull request #6546 from influxdata/er-build-tag
Fix invalid build tag
2016-05-03 16:00:39 +01:00
Jonathan A. Sternberg a2a5c32770 Merge pull request #6539 from influxdata/js-6495-fix-aggregates-with-empty-shards
Fix aggregate returns when data is missing from some shards
2016-05-03 10:56:21 -04:00
Ben Johnson 49eb3b8d04
optimize show series iterator
This commit changes the `SeriesIterator` to process one measurement
at a time and uses a `floatFastDedupeIterator` to avoid point
encoding during deduplication.
2016-05-03 08:52:44 -06:00
Jonathan A. Sternberg d6d0addcec Fix aggregate returns when data is missing from some shards
If a shard is empty for a specific field and the field type is something
other than a float, a nil iterator would get returned from one of the
empty shards and cause the combined iterators to be cast to the float
type and all other iterator types to be discarded (or for integers, to
be cast).

This is rare since most aggregates don't accept strings or booleans, but
for queries like:

    SELECT distinct(string) FROM mydata

It would result in nothing getting returned if one of the shards didn't
have a value for `string`.

This change modifies the query engine to return nil for the shards
instead of a fake iterator and then to only use the fake iterator if the
final aggregate iterator is nil (meaning that no iterators could be
constructed for the field from any shard).

Fixes #6495.
2016-05-03 10:41:22 -04:00
Edd Robinson d35fa1ec97 Remove redundant windows build tags 2016-05-03 14:22:02 +01:00
Jason Wilder d82aa98951 Reduce indentation in filter func 2016-05-02 11:38:25 -06:00
Jason Wilder e0304ae3d5 Fix shards not getting assigned to series on restart
Also, simplifies the LoadMetaDataIndex func to not require a *Shard
2016-05-02 11:36:05 -06:00
Jason Wilder 2d09937fd2 Fix removing fully deleted index blocks
If multiple tombstone entries happen to exist for the same key in a
tombstone file, it was possible to panic.  The first application
would remove all index entries and the second time around the code
still assumed entries would exist and would index into the nil slice.

Also fixes a case where the range of time would fully delete all index
entries, but it did not align with math.MinInt64 and math.MaxInt64.  This
would cause the index locations to still exist in the offset slice.  This
is inefficient because the BlockIterator would still scan and decode the block
only to discover that all the values are deleted.  We now just remove it from
the offsets slice in this case since the range of values are deleted.
2016-05-02 11:36:05 -06:00
Jason Wilder 58aa65d5a8 Optimize applyTombstones
When a large tombstone file existed on disk, this code was slow since
it would apply each tombstone to the index one at a time causing the
index to be scanned for each key.

Instead, we group all the tombstones together by timestamp and apply
in bulk so that the index in scan once for each set of tombstones.

If we change to immuntable tombstone files, it might be better to just
write a file where all the keys have the same tombstone so we can re-apply
them efficiently.
2016-05-02 11:36:05 -06:00
Jason Wilder c73c7cea25 Revert filtering index entries in BlockIterator
This was the wrong fix.  The real issue was the tombstones were
being read incorrectly and also applied incorrectly at times.  This
code is slower and not necessary so reverting it.
2016-05-02 11:36:04 -06:00
Jason Wilder 3a7429886e Optimize Measurement.DropSeries 2016-05-02 11:36:04 -06:00
Jason Wilder f9ace932c0 Fix V2 tombstone reading file position
Each iteration of the loop was incrementing the position by 4 incorrectly.
The position should start at four since the header is 4 bytes.  This
caused tombstones at the end of the file to not be read because the counter
was out of sync with the actual file position which cause the loop to exit early.

Probably better to refactor this to check for io.EOF instead of using the counter.
2016-05-02 11:36:04 -06:00
Jason Wilder 61e0d8ff93 Fix log prefix formatting 2016-05-02 11:36:04 -06:00
Jason Wilder bd1009080e Prevent writing empty tombstone files
If you delete from a measurement with a tag those does not match
any series, we would write a empty tombstone file and file to load
it back.
2016-05-02 11:36:04 -06:00
Jason Wilder 8082fc61ba Fix parsing keys when loading database index
The code for parsing a key our of the WAL or TSM files in the engine
was naive and didn't account for measurements with escape chars. This
uses the correct parsing code to parse and load them correctly.

Fixes #6496
2016-04-30 14:47:19 -06:00
Todd Persen 9eb4c1ec57 Fix typo in comment. 2016-04-29 16:26:27 -07:00
Jason Wilder abcb559b09 Remove index meta data when series and measurements are gone
This remove the dropMeta param from the tsdb.Store.DeleteSeries and
lets the shard determine when to remove the meta data from the index
based on what series still have data in the shard.

This uncovered a nasty bug in compactions where a fully deleted series would
prematurely end the compactions and not carry forward the rest of the data
in the TSM file.  This is now fixed as well.
2016-04-29 16:31:57 -06:00
Edd Robinson 4d1cfa887c Ensure measurement dropped when no more series 2016-04-29 00:05:42 +01:00
Jason Wilder 2bd5880d7a Remove series from index when shard is closed
When a shard is closed and removed due to retention policy enforcement,
the series contained in the shard would still exists in the index causing
a memory leak.  Restarting the server would cause them not to be loaded.

Fixes #6457
2016-04-28 12:34:46 -06:00
Jason Wilder 4e353867d5 Fix first block not getting purged when deleting series 2016-04-27 17:08:00 -06:00
Ben Johnson f7af787aef
add DELETE query support
This commit adds query language support for deleting series with a
`DELETE` query.
2016-04-27 15:16:23 -06:00
Jason Wilder aefd2ad08b Add DeleteSeries and DeleteSeriesRange 2016-04-27 13:09:53 -06:00
Jason Wilder c306090361 Fix tombstone rename on windows 2016-04-27 13:09:53 -06:00
Jason Wilder 86d37614e4 Remove debugging from test output 2016-04-27 13:09:53 -06:00
Jason Wilder bf3aa5857d Don't add tombstone for timerange not contained by file 2016-04-27 13:09:53 -06:00
Jason Wilder 6042e114a1 Remove tombstoned values during compaction
This will skip blocks that are fully tombstoned as well as remove
points that have been removed within a block.
2016-04-27 13:09:53 -06:00
Jason Wilder 23bbfb2192 Prevent truncated WAL entries from panicing 2016-04-27 13:09:53 -06:00
Jason Wilder 0de21ade40 Add delete range of values support to WAL and cache loader 2016-04-27 13:09:53 -06:00
Jason Wilder d13d01b516 Allow deleting series by time on a shard 2016-04-27 13:09:53 -06:00
Jason Wilder 4d71d2b01f Add support for deleting cache values using time range 2016-04-27 13:09:52 -06:00
Jason Wilder c154cd4b4a Remove TSMReaderOptions
Not used
2016-04-27 13:09:52 -06:00
Jason Wilder c8bd41c2d8 Remove TSM reader Keys func
It's very inneficient and should never be used.
2016-04-27 13:09:52 -06:00
Jason Wilder 7e06d558d5 Update ContainsValue to handle tombstones 2016-04-27 13:09:52 -06:00
Jason Wilder 97504a552c Support time range tombstones in FileStore/KeyCursor 2016-04-27 13:09:52 -06:00
Jason Wilder 27c2bc3f15 Sepearate IndexWriter from TSMIndex
Allows for future versionion of the TSMIndex as well as removing
a lot of unnecessary code.
2016-04-27 13:09:52 -06:00
Jason Wilder bb82331db7 Move TSMIndex defn to reader.go 2016-04-27 13:09:52 -06:00
Jason Wilder 1ac0b01c5a Remove fileAccessor
No longer used
2016-04-27 13:09:52 -06:00
Jason Wilder a789e819a3 Remove NewTSMReaderWithOptions
There are two TSMIndex implementations, the directIndex and the
indirectIndex.  Originally, we only had the directIndex and later
added the indirectIndex and NewTSMReaderWithOptions in order to
allow both indexes to be used in tests and code.  This has created
a problem since we really only use the directIndex for writing and
always use the indirectIndex for reading.

This changes removes the NewTSMReaderWithOptions func so that it is
no longer possible to create a TSMReader with a directIndex.  This
will allow a lot of the block reading code used by the directIndex
to be removed and simplify maintainence.  It also gives better test
coverage of the code that is actually used by the TSM engine now.
2016-04-27 13:09:52 -06:00
Jason Wilder bc6328d196 Add time range support to tombstone files
This adds support for a time range to tombstone files to allow a subset
of points to be deleted instead of the whole series.  It changes the
tombstone file format to a binary format and maintains backwards compatibility
with the old text format tombstone files.
2016-04-27 13:09:52 -06:00
Tait Clarridge df0e16a92f Add safer unlock to CreateFieldIfNotExists
A deadlock can occur if the field was created while we were waiting for the lock.
2016-04-25 12:44:58 -04:00
Ben Johnson 9c1fa76f3c Merge pull request #6452 from benbjohnson/simple8b
update dep: simple8b @ b421ab40
2016-04-22 11:05:42 -06:00
Ben Johnson 286072f65a
update dep: simple8b @ b421ab40 2016-04-22 09:46:05 -06:00
Jonathan A. Sternberg d26e4e3650 Pass binary expressions to the underlying query
Binary math inside of a where condition was previously disallowed. Now,
these types of queries are just passed verbatim down to the underlying
query engine which can handle it.

We may want to revisit this when it comes to tags at some point as it
prevents the more efficient filtering of tags that a simple expression
allows, but it allows a query like this to be done:

    SELECT * FROM cpu WHERE value + 2 < 5

So while it can be better, this is a good initial implementation to
provide this functionality. There are very rare situations where a tag
may be used appropriately in one of these circumstances.

Fixes #3558.
2016-04-22 11:30:36 -04:00
Ben Johnson d204a8b683
optimize tsm1.FloatDecoder
This commit changes the `FloatDecoder.val` from a `float64` type
to a `uint64` to avoid an additional type conversion during read.
Now the type gets converted to a `float64` only on call to `Values()`.
2016-04-21 08:49:12 -06:00
Jason Wilder 87ceb7426a Don't lock the cache while adding entries
Entries have their own locking so the cache doesn't need to be lock
when adding to them.
2016-04-20 16:08:58 -06:00
Jason Wilder 89aeaafd50 Re-use the string point key 2016-04-20 16:08:58 -06:00
Jason Wilder fbaa7db54f Don't lock entry when scanning new values to add 2016-04-20 16:00:26 -06:00
Jason Wilder bfa225f149 Merge pull request #6430 from influxdata/jw-cache-load-size
Disable cache max memory size when reloading the cache
2016-04-20 14:35:23 -06:00
Stephen Gutekanst 9dc09c5257 Make logging output location more programmatically configurable (#6213)
This has various benefits:

- Users embedding InfluxDB within other Go programs can specify a different logger / prefix easily.
- More consistent with code used elsewhere in InfluxDB (e.g. services, other `run.Server.*` fields, etc).
- This is also more efficient, because it means `executeQuery` no longer allocates a single `*log.Logger` each time it is called.
2016-04-20 21:07:08 +01:00
Jason Wilder f679787080 Disable cache max memory size when reloading the cache
The cache max memory size is an approximate size and can prevent a
shard from loading at startup.  This change disable the max size
at startup to prevent this problem and sets the limt back after
reloading.

Fixes #6109
2016-04-20 10:41:30 -06:00
Jonathan A. Sternberg c8c38e15cd Merge pull request #6386 from influxdata/js-iterator-next-error
Modify all of the iterators to allow returning an error on Next()
2016-04-20 10:39:53 -04:00
Ben Johnson 54454e1e5b Merge pull request #6424 from benbjohnson/optimize-bit-reader
Optimize tsm1.BitReader
2016-04-20 08:28:24 -06:00
Seif Lotfy c6e3c87e00 Add Block checksum validation and "influx_inspect verify" tool
Fixes #5502
2016-04-19 22:33:03 +02:00
Jonathan A. Sternberg 493ef0e1ce Merge pull request #6416 from influxdata/js-3166-deterministic-limit
Sort the series keys inside of a tag set so the output is deterministic
2016-04-19 14:49:49 -04:00
Ben Johnson 1d2238c642
optimize tsm1.BitReader
This commit rewrites the `tsm1.BitReader` to use an 8-byte buffer
instead of a 1-byte buffer and provide an inlineable fast bit read.
2016-04-19 11:34:17 -06:00
Jason Wilder f841a90d35 Use int64 instead of time.Time in timestamp encoder/decoder 2016-04-19 10:25:27 -06:00
Jason Wilder 61beeca426 Update timestamp benchmarks 2016-04-19 10:17:32 -06:00
Jonathan A. Sternberg 09c46a451a Sort the series keys inside of a tag set so the output is deterministic
The series keys within a tag set were previously not sorted which would
cause the output to be non-deterministic. This sorts the output series
by their keys so it has a consistent output especially when using
limits.

Fixes #3166.
2016-04-18 17:45:31 -04:00
Jonathan A. Sternberg 7ec2a991d5 Modify all of the iterators to allow returning an error on Next()
This also switches the remaining iterators to be lazy so they can return
errors properly. They needed to be converted to lazy initialization
anyway, which has the side effect of making it much easier for us to
propagate the underlying error during initialization.

Updated the Emitter to return errors when it cannot read properly from
the iterators.
2016-04-18 11:17:55 -04:00
Jonathan A. Sternberg 93745d9693 Merge pull request #6391 from influxdata/js-5553-limit-queries-slow-with-group-by
Propagate the limit option to the low level iterators
2016-04-16 09:39:25 -04:00
Jonathan A. Sternberg bd5fdd797d Propagate the limit option to the low level iterators
When a GROUP BY or multiple sources are used, the top level limit
iterator requires reading the entire iterator stream so it can find all
of the tag groups it needs to return. For large data series, this ends
up with the limit iterator discarding a lot of output.

This change adds a new lower level limit iterator on each series itself
so that there are fewer data points that have to be thrown away by the
top level iterator.

Fixes #5553.
2016-04-15 18:23:54 -04:00
Jonathan A. Sternberg 835d08591e Do not filter out empty tags from series keys 2016-04-13 09:15:57 -04:00
Jonathan A. Sternberg 60282cf52d Merge pull request #6284 from influxdata/js-3371-where-clause-compare-tags-and-fields
Enhance comparing tags and fields in the where clause
2016-04-12 11:45:54 -04:00
Pierre Fersing 29b19a2293 Fix deadlock in tsm1/file_store 2016-04-12 09:39:21 +02:00
Jonathan A. Sternberg ea6262b712 Enhance comparing tags and fields in the where clause
Now it is possible to compare tags and fields and it is also now
possible to compare tags and tags. Previously, it was only possible to
compare fields with fields and tags with a string or a regex.

Fixes #3371.
2016-04-11 18:10:08 -04:00
Ben Johnson 525e22c92b
tsm1 query engine alloc reduction
This commit makes a number of performance improvements to
reduce allocations during query execution. Several objects
and buffers are now reused across the components to avoid
allocations.

Previously a simple `count(value)` query across 1M points
would require 26,000+ allocations. After the changes in
this commit that number has been reduced to 88.
2016-04-11 14:50:59 -06:00
Jonathan A. Sternberg 5bdd61bde7 Support empty tags for all WHERE equality operations
A missing tag on a point was sometimes treated as `""` and sometimes
treated as a separate `null` entity. This change modifies the equality
operations to always treat a missing tag as an empty string.

Empty tags are *not* indexed and do not have the same performance as a
tag that exists.

Fixes #3773.
2016-04-11 12:01:35 -04:00
Edd Robinson 5327a75a6f Merge pull request #6216 from influxdata/er-scope-proto
Change protobuf package names to avoid clashes
2016-04-07 16:38:21 +01:00
Jonathan A. Sternberg a58430bb60 Merge pull request #6217 from influxdata/js-tsdb-unused-code
Remove unused code and increase some test coverage for the tsdb package
2016-04-06 10:07:43 -04:00
Jonathan A. Sternberg 028fdaff81 Merge pull request #6222 from influxdata/js-6206-descending-tsm1-iterators
Handle nil values from the tsm1 cursor correctly
2016-04-06 10:05:20 -04:00
Jonathan A. Sternberg 94ec92d669 Handle nil values from the tsm1 cursor correctly
Send nil values from the tsm1 cursor at the end of the cursor. After the
cursor reached tsm1, the `nextAt()` call would always return the default
value rather than a nil value.

Descending also didn't work correctly because the seeking functionality
for tsm1 iterators would always act like they were ascending instead of
descending when choosing which value to select. This resulted in very
strange output from the emitter since it couldn't figure out if it was
ascending or descending.

Fixes #6206.
2016-04-06 09:27:02 -04:00
Jonathan A. Sternberg 7a229c7e4e Remove unused code and increase some test coverage for the tsdb package 2016-04-06 09:24:56 -04:00
joelegasse 84f8dd7c85 Merge pull request #6190 from influxdata/jw-race
Fix race on measurementFields
2016-04-06 08:13:58 -04:00
Edd Robinson 184257a10d Scope all internal protobuf packages 2016-04-05 13:54:21 +01:00
Jonathan A. Sternberg 37b63cedec Cleanup QueryExecutor and split statement execution code
The QueryExecutor had a lot of dead code made obsolete by the query
engine refactor that has now been removed. The TSDBStore interface has
also been cleaned up so we can have multiple implementations of this
(such as a local and remote version).

A StatementExecutor interface has been created for adding custom
functionality to the QueryExecutor that may not be available in the open
source version. The QueryExecutor delegate all statement execution to
the StatementExecutor and the QueryExecutor will only keep track of
housekeeping. Implementing additional queries is as simple as wrapping
the cluster.StatementExecutor struct or replacing it with something
completely different.

The PointsWriter in the QueryExecutor has been changed to a simple
interface that implements the one method needed by the query executor.
This is to allow different PointsWriter implementations to be used by
the QueryExecutor. It has also been moved into the StatementExecutor
instead.

The TSDBStore interface has now been modified to contain the code for
creating an IteratorCreator. This is so the underlying TSDBStore can
implement different ways of accessing the underlying shards rather than
always having to access each shard individually (such as batch
requests).

Remove the show servers handling. This isn't a valid command in the open
source version of InfluxDB anymore.

The QueryManager interface is now built into QueryExecutor and is no
longer necessary. The StatementExecutor and QueryExecutor split allows
task management to much more easily be built into QueryExecutor rather
than as a separate struct.
2016-04-04 13:27:17 -04:00
Jason Wilder ca8b0ca143 Optimize locking in CreateFieldIfNotExists
Also remove some dead code that is no longer relevant with tsm.
2016-04-01 20:44:40 -06:00
Jason Wilder 3f4c5a5585 Fix race on measurementFields
Both Shard and Engine had the same reference to the measurementField map,
but they each protected it with their own locks.  This causes a race when
write and queries are occurring because writes can add new fields to the
map while queries are reading from it.

The fix moves the ownership to the Engine and provides protected accessors
to that Shard now users.  For the most parts, the access on shard were old
dead code.

Fixing the measurementFields map race created a new race on the internal
fields map.  This is now unexported and protected via MeasurementFields
exported funcs.

Fixes #6188
2016-04-01 18:57:01 -06:00
Jason Wilder 07e3215d11 Remove ununsed Series.match func 2016-03-31 10:19:46 -06:00
Jason Wilder 40c4973423 Remove per measurement stats collection
The stats setup ends up creating a lot of lock contention which signifcantly
impacts write throughput when a large number of measurements are used.

Fixes #6131
2016-03-31 10:19:27 -06:00
Jason Wilder f1bb87d4f8 Convert index write lock to series lock 2016-03-31 10:19:27 -06:00
Edd Robinson 8e2d1e48c7 Check if engine closed. Fixes #6140 2016-03-31 15:59:04 +01:00
Edd Robinson 75a2218fa1 Ensure syncronised access to engine 2016-03-31 15:58:19 +01:00
Jason Wilder 873ac2715d Fix panic: runtime error: slice bounds out of range
Writing a key that exceeds the max key length could cause a panic
when reading a tsm file because the 2 bytes used for the key length
would not be enough to represent the actual key length.

The writer will now return an error if when trying to write a key
that is too large.
2016-03-30 23:44:17 -06:00
Jonathan A. Sternberg 711a6614e6 Implement the point limit monitor
Fixes #6077.
2016-03-30 16:08:56 -04:00
Joe LeGasse f10c300765 Update to conversion tool to work in current versions
After adding type-switches to the tsm1 packages, the custom
implementation found in the conversion tool broke. This change uses
tsm1.NewValue() instead of a custom implementation.

This change also ensures that the tsm1.Value interface can only be
implemented internally to allow for the optimized type-switch based
encoding
2016-03-30 13:26:46 -04:00
Jason Wilder 9f41acba2f Move shard mapping logic into index 2016-03-29 12:59:27 -06:00
Jason Wilder 60c3898577 Add godoc for KeyAt func 2016-03-29 12:59:26 -06:00
Jason Wilder 1b08e2dd55 Use walk func to load all tsm keys to index
Avoids allocating a big map or all keys.
2016-03-29 12:59:26 -06:00
Jason Wilder 96e076b6df Limit how many shards are loaded concurrently
Since loading a shard can allocate a lot of memory, running them all
at once could OOM the process.  This limits the number of shards
loaded to 4.  This will be changed to a config option provided the
approach helps.
2016-03-29 12:59:26 -06:00
Jason Wilder d4757ad040 Remove sync.Pool from wal UnmarshalBinary
When loading many shards concurrently they block trying to
acquire a write lock in the sync pool adding a new source of
contention.  Since this code flow always needs to allocate a
buffer it's not really buying us much.
2016-03-29 12:59:26 -06:00
Jason Wilder 3f0e871425 Reduce lock content when loading database index 2016-03-29 12:59:26 -06:00
Jason Wilder 03ced4cc90 Load shards concurrently 2016-03-29 12:58:52 -06:00
Ben Johnson 45f1c28adb add tsm iterator stats buffer
This commit adds a buffer for stats to be updated without
requiring a mutex lock/unlock on every point. The tradeoff
is that stats are not exactly precise. This works for our
use case because stats are only periodically checked.
2016-03-23 12:23:22 -06:00
Jonathan A. Sternberg a35d9602cd Fix where filters when a OR is used and when a tag does not exist
If an OR was used, merging filters between different expressions would
not work correctly. If one of the sides had a set of series ids with a
condition and the other side had no series ids associated with the
expression, all of the series from the side with a condition would have
the condition ignored. Instead of defaulting a non-existant series
filter to true, it should just be false and the evaluation of the one
side that does exist should take care of determining if the series id
should be included or not. The AND condition used false correctly so did
not have to be changed.

If a tag did not exist and `!=` or `!~` were used, it would return false
even though the neither a field or a tag equaled those values. This has
now been modified to correctly return the correct series ids and the
correct condition.

Also fixed a panic that would occur when a tag caused a field access to
become unnecessary. The filter using the field access still got created
and used even though it was unnecessary, resulting in an attempted
access to a non-initialized map.

Fixes #5152 and a bunch of other miscellaneous issues.
2016-03-22 12:19:06 -04:00
Ben Johnson 573dd0f96a Merge pull request #6035 from benbjohnson/query-engine-reduce-alloc
Reduce allocations in query execution
2016-03-22 10:11:14 -06:00
Ben Johnson 6e1c1da25b reduce allocations in query execution
This commit removes some heap objects by converting them from
pointer references to non-pointers or by reusing buffers.
2016-03-22 09:51:39 -06:00
Jason Wilder 7857e07a1e Merge pull request #6062 from influxdata/mr-prune-wal-config
Remove unused WAL configuration variables/fields
2016-03-22 09:20:27 -06:00
Jonathan A. Sternberg ad96207868 Fix ORDER BY desc so it doesn't skip values
After reading the initial buffer, ORDER BY desc would read the next
block into the buffer and only read the first element. It's because the
code that was copied from the ascending cursor wasn't modified correctly
to set the position to the last element in the buffer.

The buffer size has also been lowered from 1000 to 10 to match with the
ascending cursor for performance with limit queries.

Fixes #6055.
2016-03-22 09:40:11 -04:00
Ben Johnson 7156c1f9bd add IteratorStats
This commit adds an `IteratorStats` that holds aggregate
iterator processing information. A method is also added to
`Iterator` to return the stats:

	Stats() influxql.IteratorStats

The remote iterators will also emit their stats in the point
stream upon first connection, on a given interval, and then
finally once the last point has been sent.
2016-03-21 16:25:19 -06:00
Jason Wilder ee2f21e76f Merge pull request #6082 from influxdata/jw-tsm
Fix partially written TSM files
2016-03-21 15:42:27 -06:00
Jason Wilder 7567453c9a Ensure TSM files are fsync'd
Make sure TSM files are fsync'd when closed and also that the parent
dir is fsync'd when they are renamed.
2016-03-21 15:03:52 -06:00
Jason Wilder a4e5446ddd Return error when TSM writer close returns one
The TSM writer uses a bufio.Writer that needs to be flushed before
it's closed.  If the flush fails for some reason, the error is not
handled by the defer and the compactor continues on as if all is good.
This can create files with truncated indexes or zero-length TSM files.

Fixes #5889
2016-03-21 15:00:36 -06:00
Jonathan A. Sternberg 6655ca7769 Create a new interrupt iterator that will stop emitting points after an interrupt
Use of the iterator is spread out into both `IteratorCreators` and
inside of the iterators themselves. Part of the interrupt must be
handled inside of the engine so it stops trying to emit points when an
interrupt is found and another part of the interrupt has to happen when
combining the iterators so it doesn't just start reading the next shard.
2016-03-21 12:07:07 -04:00
Mark Rushakoff 7a2adfcc5d Remove unused WAL configuration variables/fields
These were all b1/bz1 settings that no longer have any effect:

- {Default,}MaxWALSize
- {Default,}WALFlushInterval
- {Default,}WALPartitionFlushDelay
- {Default,WAL}ReadySeriesSize
- {Default,WAL}CompactionThreshold
- {Default,WAL}MaxSeriesSize
- {Default,WAL}FlushColdInterval
- {Default,WAL}PartitionSizeThreshold
2016-03-20 13:16:52 -07:00
Jonathan A. Sternberg d75428f79f Rename the special condition "name" to "_name" to reduce conflicts
Fixes #6034.
2016-03-16 17:17:04 -04:00
Jonathan A. Sternberg eb2d49dbe4 Merge pull request #6007 from benbjohnson/explicit-system-names
Allow querying of system-like series
2016-03-15 16:15:17 -04:00
Cory LaNou ba6a95e9bc Merge pull request #5994 from influxdata/single-server-lite
Single Server
2016-03-14 16:11:37 -05:00
Ben Johnson f692621ef5 allow querying of system-like series
Internal system series start with an underscore prefix but
restricting this prevents users who already use an underscore
prefix in their series names.

Fixes #5870
2016-03-14 13:50:52 -06:00
Jason Wilder 3fd40d48a1 Merge pull request #6006 from influxdata/jw-deadlock
Fix deadlock when running backup
2016-03-14 13:36:45 -06:00
Jason Wilder 9984cd5d6d Fix skipping blocks at query time when overlaps exist
Depending on how data is written across TSM files, it was possible
to skip over some blocks at query time making it looks like data was missing.
2016-03-14 13:11:11 -06:00
Jason Wilder 000459e350 Fix deadlock when running backup
A deadlock occurs under write load if a backup is run in between the
time when a snapshot compactions has snapshotted the cache and successfully
written it to disk.  The issus is that the second snapshot call will block
on the commit lock while it is holding the engine write lock.  This causes
all writes to block as well as prevents the currently runnign snapshot
compaction from completing because it needs to acquire a read-lock.

This PR removes the commit lock and just returns an error if a snapshot is
in progress to all any locks being held to be released.  The caller can determine
whether to retry or giveup.
2016-03-14 12:36:48 -06:00
Cory LaNou 27cfaa4b7a in memory meta, single node configs, etc. 2016-03-14 16:55:54 +00:00
Joe LeGasse 344e5abd41 Changed type-switch a few places to reduce allocations.
Slices of tsm1.Value interfaces are only ever used with all the same
types, and the previous code would switch on the type returned from a
call to Value(), which allocated and returned an interface{} object for
the underlying value.

This change instead type-switches on the tsm1.Value object itself,
allowing it direct access to the underlying value field, eliminating the
unecessary allocations.
2016-03-11 15:57:05 -05:00
Ben Johnson beda072426 add support for remote expansion of regex
This commit moves the `tsdb.Store.ExpandSources()` function onto
the `influxql.IteratorCreator` and provides support for issuing
source expansion across a cluster.
2016-03-11 12:40:07 -07:00
Jason Wilder c44195d999 Convert measurementToRegex to exported func
Make it consistent with other conventions where exported funcs
take a lock.
2016-03-09 17:45:37 -07:00
Jason Wilder 992c78ee22 Remove period shard maintenance goroutine
This is no longer used in tsm and just peridocially locks everything
for no reason now.
2016-03-09 17:31:02 -07:00
Jason Wilder ae2360df7c Use read lock to expand sources
A write-lock was taken which locks the whole store during a query
that needs to expand sources.  Under load, writes can start to fail.
2016-03-09 17:22:57 -07:00
Edd Robinson 7dbc0f49d3 Merge pull request #5818 from influxdata/er-upgrade-error
Highlight upgrade info for old shards
2016-03-09 19:39:59 +00:00
Edd Robinson 58c03448aa Merge pull request #5514 from influxdata/er-engine-panic
Ensure shards and engine are safely closed
2016-03-09 18:56:36 +00:00
Ben Johnson 41dde61226 SHOW SERIES 2016-03-08 11:47:57 -07:00
Jonathan A. Sternberg 2f0e246757 Implemented the tag values iterator for `SHOW TAG VALUES`
`SHOW TAG VALUES` output has been modified to print the measurement name
for every measurement and to return the output in two columns: key and
value. An example output might be:

    > SHOW TAG VALUES WITH KEY IN (host, region)
    name: cpu
    ---------
    key     value
    host    server01
    region  useast

    name: mem
    ---------
    key     value
    host    server02
    region  useast

`measurementsByExpr` has been taught how to handle reserved keys (ones
with an underscore at the beginning) to allow reusing that function and
skipping over expressions that don't matter to the call.

Fixes #5593.
2016-03-06 09:52:34 -05:00
Jason Wilder e3fef5593c Merge pull request #5855 from jonseymour/jss-5854-go-master-breaks-build
fix tests to cope with future changes to testing.quick.Check - see #5854
2016-03-01 19:03:21 -07:00
Mark Rushakoff cdcb079769 Tag TSM stats with database, retention policy
... 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.
2016-02-29 09:17:34 -08:00
Jon Seymour 73b3a2a056 Merge #5855 (issue: #5854).
RHS merges cleanly with 0.10.0

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-29 20:37:32 +11:00
Jon Seymour 716cdd7f41 tsm: modify encoding tests to deal with possible nil slices from testing.quick.Check in go master
The current go compiler at the tip of the go master (1d5001af) has a modified implementation of
testing.quick.Check that now generates nil slices as test data. (See: https://gophers.slack.com/archives/general/p14567053570110). The existing tests expect round tripping to work in this case
but it does not. So, in these cases we change the expectation to reflect actual behaviour.

This needs to be checked for reasonableness.
2016-02-29 20:36:19 +11:00
Jonathan A. Sternberg aa0b603938 Convert `SHOW FIELD KEYS` to the new query engine
Fixes #5579.
2016-02-25 18:31:02 -05:00
Jason Wilder 8d70d65a82 Convert time.Time to int64 2016-02-25 15:15:01 -07:00
Jason Wilder 55a503671d Merge pull request #5833 from jonseymour/jss-5832-snapshot-may-not-be-sorted
tsm: cache: need to check that snapshot has been sorted
2016-02-25 15:10:49 -07:00
Mark Rushakoff 40a98e0d55 Add database, RP as tags on shard stats
This commit updates tsdb.Shard to contain a ShardConfig and updates
tsdb.Store to directly reference a map of tsdb.Shard rather than the
previous tsdb.shardLocation abstraction.
2016-02-25 13:41:55 -08:00
Jon Seymour 11123d2694 Merge #5833 (issue: #5832).
Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-26 07:59:03 +11:00
Jon Seymour 2c7cd06b99 tsm: cache: need to check that snapshot has been sorted.
Previously, the for loop at the end of the method assumed that all entries
had been deduplicated, including the entry discovered in the snapshot.

However, this wasn't actually true. With this change, we make it true.

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-26 07:56:25 +11:00
Jon Seymour 7eabae68de tsm: cache: add a test for the write sequence {6,1,snapshot,7,2}
Consider the write sequence: 6,1,snapshot,7,2.

The hot cache gets deduplicated, so is 2,7.

Now consider the test if 1 >= 2, this is false, so needSort is not set to true.

The problem is the implicit assumption that the snapshot is always sorted
by the time that merged() runs, but this may not be true.

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-26 07:43:50 +11:00
Jason Wilder 6ebc192298 Merge pull request #5678 from jonseymour/typo
doc: typographical, spelling, grammar, word-choice and phrasing improvements.
2016-02-25 09:33:41 -07:00
Jason Wilder daf68dbbd2 Merge pull request #5701 from jonseymour/js-deduplicate-safety
tsm: cache: improve thread safety of Cache.Deduplicate (see #5699)
2016-02-25 09:18:10 -07:00
Mark Rushakoff e7bb855ab2 Merge pull request #5816 from influxdata/mr-database-stats
Track stats for number of series, measurements
2016-02-25 08:13:04 -08:00
Ben Johnson 0dda9f6608 add remote execution
This commit adds remote execution to the query engine.
2016-02-25 08:41:20 -07:00
Jon Seymour 4d98a1cf28 tsm: cache: remove unnecessary lock escalation.
Previously, we needed a write lock on the cache because it was the
only lock we had available to guard updates to entry.values and
entry.needSort.

However, now we have a entry-scoped lock for this purpose, we don't
need the cache write lock for this purpose. Since merged() doesn't
modify the .store or the c.snapshot.sort, there is no need for
a write lock on the cache to protect the cache.

So, we don't need to escalate here - we simply rely on the entry lock
to protect the entries we are iterating over.

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-26 01:31:54 +11:00
Edd Robinson aa845cec7e Check for shards needing conversion. Fixes #5723 2016-02-25 13:21:13 +00:00
Jason Wilder 452d77cbaf tsm: cache: introduce entry locks.
Based on @jwilder's alternative to the 'dirty' slice that featured
in previous iterations of this fix.

Suggested-by: Jason Wilder <jason@influxdb.com>
Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-26 00:05:38 +11:00
Jon Seymour eb7eec078d tsm: cache: introduce commit lock to Cache
Currently two compactors can execute Engine.WriteSnapshot at once.

This isn't thread safe since both threads want to make modifications to
Cache.snapshot at the same time.

This commit introduces a lock which is acquired during Snapshot() and
released during ClearSnapshot(), ensuring that at most one thread
executes within Engine.WriteSnapshot() at once.

To ensure that we always release this lock, but only release the
snapshot resources on a successful commit, we modify ClearSnapshot() to
accept a boolean which indicates whether the write was successful or not
and guarantee to call this function if Snapshot() has been called.

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-25 12:10:37 +11:00
Jon Seymour 45d025db99 tsm: cache: add a tests to demonstrate thread safety vulnerabilities
There are two tests that show two different one vulnerability.

One test shows that Cache.Deduplicate modifies entries in a snapshot's
store without a lock while cache readers are deduplicating those same
entries while correctly locked.

A second test shows that two threads trying to execute the methods
that Engine.WriteSnapshot calls will cause concurrent, unsynchronized
mutating access to the snapshot's store and entries.

The tests fail at this commit and are fixed by subsequent commits.

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-25 12:10:31 +11:00
Jon Seymour d7d81f79da tsm: cache: add a test that demonstrates concurrent reads are safe
Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-25 12:06:10 +11:00
Mark Rushakoff fb83374389 Track stats for number of series, measurements
Per database: track number of series and measurements
Per measurement: track number of series
2016-02-24 08:10:16 -08:00
Edd Robinson 16995b6c23 Add ShardError to provide context about shard that errored 2016-02-24 13:33:07 +00:00
Jon Seymour 530b86ba7d tsm: cache: restore the semantics of cachedBytes and memSize stats
Fixes #5805.

This commit undoes a regression introduced by #5789.

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-24 06:16:46 +11:00
Jon Seymour 3475356dc9 tsm: cache: fix semantics of snapshotCount statistic to make it useful.
Fix for #5804.

The commit for #5789 rendered the semantics of snapshotCount statistic
useless. This commit restores semantics that have diagnostic value to
this statistic.

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-24 06:13:54 +11:00
Jason Wilder 017c24c98e Simplify cache snapshotting
The Cache had support for taking multiple snapshots to support writing
multiple snapshots to TSM files concurrently if that happened to be
a bottleneck.  In practice, this is never a bottleneck and we only
run one snappshoting goroutine continously per shard which has worked
well for all workloads.

The multiple snapshot support introduces some unhandled failure scenarios
where wal segments could be removed without writing them to TSM files.  If
a snapshot compaction fails to write due to transient disk errors, subsequent
snapshots will continue, but the failed one will not be retried.  When the
subsequent ones succeeded, all closed wal segments are removed causing data
loss.

This change simplifies the snapshotting capability to ensure that there is only
ever one snapshot.  If one fails, the next snapshot will update the existing
snapshot and retry all of old and new data.

Fixes #5686
2016-02-23 09:38:51 -07:00
Jonathan A. Sternberg 50753de032 Merge pull request #5782 from influxdata/js-5777-audit-panics-in-influxql
Remove the non-unreachable panics in the new query engine
2016-02-22 17:18:57 -05:00
Mark Rushakoff 191de2670c Fix non-compiling test 2016-02-22 13:49:11 -08:00
Mark Rushakoff fc5c8597ab Merge pull request #5758 from influxdata/mr-disk-stats
Track cache, WAL, filestore stats within tsm1 engine
2016-02-22 13:01:55 -08:00
Jason Wilder aa2e878019 Fix cache not deduplicating points in some cases
The cache had some incorrect logic for determine when a series needed
to be deduplicated.  The logic was checking for unsorted points and
not considering duplicate points.  This would manifest itself as many
points (duplicate) points being returned from the cache and after a
snapshot compaction run, the points would disappear because snapshot
compaction always deduplicates and sorts the points.

Added a test that reproduces the issue.

Fixes #5719
2016-02-22 13:24:42 -07:00
Jonathan A. Sternberg 7a03df2af1 Remove the non-unreachable panics in the new query engine
The only panics left are ones that should be unreachable unless there is
a bug.

Fixes #5777.
2016-02-22 12:52:43 -05:00
Jon Seymour c93da21a61 tsm: cache: only use NewCache for engine cache's snapshots use a simpler constructor
The intent of this change is to avoid writing caches created for
snapshot cache instances into the tsm1_cache measurement. We can do
this by avoiding use of the NewCache constructor. All other methods
are only intended to be called from on the engine cache - never
on a snapshot.

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-22 15:17:43 +11:00
Jon Seymour 510ee2c790 tsm: cache: during writes, update the memSize statistic outside the lock
Since we are not locking but relying on atomic arithmetic,
use Add rather than Set. Will also result in slightly less garbage
being created.

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-22 08:26:35 +11:00
Jon Seymour 9c6efe99f1 tsm: cache: ensure all statistics are initialised on cache creation.
The intent of this change is to ensure that all statistic fields of the
resulting tsm1_cache measurement are initialized on initialization of
the cache. That way, any consumer of those measurements doesn't
have to deal with the null case.

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-21 15:33:50 +11:00
Jon Seymour 6697c721fb tsm: cache: add cache throughput related statistics.
Complementing and extending the changes in #5758.

Add 2 level statistics:

  * snapshotCount
  * cacheAgeMs

Add 2 counter statistics

  * cachedBytes
  * WALCompactionTimeMs

snapshotCount can be used to measure transient write errors that are causing snapshots to accumulate

cacheAgeMs can be used to guage the level of write activity into the cache

The differences between cachedBytes stats sampled at different times can be used to calculate cache throughput rates

The ratio (cachedBytes-diskBytes)/WALCompactionTimeMs can be used calculate WAL compaction throughput.

The ratio of difference between first and last WAL compaction time over the interval
length is an estimate of percentage of cache throughput consumed.

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
2016-02-20 22:18:57 +11:00
Mark Rushakoff 602043e11b Add disk stats for FileStore 2016-02-19 16:37:34 -08:00
Mark Rushakoff d99c09cedd Add stats for current and old WAL segment sizes 2016-02-19 16:37:34 -08:00
Mark Rushakoff e76967efb6 Add stats to tsm1.Cache 2016-02-19 16:37:34 -08:00