Commit Graph

301 Commits (e4539ad04d5fb6f7bc3b0e2516ebc5812036ee49)

Author SHA1 Message Date
Ben Johnson 08e24faf4c
feat(tsdb): Add block exporter.
Adds export tooling to `influxd inspect export-blocks` so that we
can dump out block data in SQL format for better analysis during
the debugging process.
2019-07-01 10:10:52 -06:00
Tanya Gordeeva fe4333e8e0 fix(storage): fix tracking disk bytes in memory 2019-06-27 16:36:00 -07:00
Tanya Gordeeva 3ff15a8b41 fix(storage): fix counts for level 4+ files
The counts wreen't adding all the level 4+ files, so the last one to be counted
would override the rest.
2019-06-27 16:36:00 -07:00
Ben Johnson b3d7986d4b
chore(tsdb): Fix read metrics declaration. 2019-06-27 09:25:27 -06:00
Ben Johnson 12549c859e
feat(tsdb): Add basic tsdb read metrics
Adds a total cursor counter and seek location counter to a new
`readMetrics` that is added to each `Engine`. Default labels group
by `engine_id` and `node_id`.
2019-06-26 16:16:24 -06:00
tmgordeeva fb69c5d06c
Merge pull request #13698 from influxdata/tg-fix-metrics
fix(storage): reduce tsm level metrics cardinality
2019-06-20 17:57:37 -07:00
Tanya Gordeeva 6428cdbce6 fix(storage): initialize tsm file metrics, update after compaction
These metrics weren't being properly intialized on opening the file store, and
weren't being properly updated on compaction.
2019-06-20 14:37:53 -07:00
Tanya Gordeeva 85dc52a93b fix(storage): reduce tsm level metrics cardinality
This should have cut off TSM file levels at 4+.
2019-06-20 14:37:33 -07:00
Ben Johnson 14980d55b8
fix(storage): Add WithCurrentGenerationFunc() for generation injection.
Adds the ability to set the current generation to use when compacting
the cache only. Previously, we used the current generation for all
files but this causes issues and we should only use the current
generation for level 1 compaction.
2019-06-20 08:54:38 -06:00
Ben Johnson a181e60d70
fix(tsdb): Fix series file count (#13770)
fix(tsdb): Fix series file count
2019-06-11 10:07:12 -06:00
Christopher Wolff a82e2cb180 chore(tsdb): skip flaky test 2019-05-30 16:29:31 -07:00
Alirie Gray 576da8f9d2 fix(swagger): add log property to task runs endpoint docs 2019-05-17 14:08:10 -07:00
Nathaniel Cook faa5fddf7b Merge branch 'master' into flux-staging 2019-05-15 10:12:14 -06:00
Christopher Wolff 52a98aae2b chore(tsdb): skip flaky test
https://github.com/influxdata/influxdb/issues/13755
2019-05-14 12:52:37 -07:00
Jacob Marble 95f28cb571
fix(series file): Sync series segment after truncate (#13836) (#13859) 2019-05-10 11:25:43 -07:00
Jacob Marble aa5c77409d
backport: Fix open/close race in SeriesFile (#13837) 2019-05-08 11:39:24 -07:00
Edd Robinson 3588c0505e fix(storage): don't remap renamed TSM file
There exists a possibility for an in-flight read on a TSMReader to read
a stale reference to an mmapped TSM file index, which has become
unmapped.

This commit resolves that issue by simply renaming the file, leaving the
original file handler open and the data mapped. The path is updated so
that if any callers need to refer to the name of the TSM file after it's
renamed, the new name will be reflected.

The orphaned file handler will be closed when the TSM file is closed.
2019-05-03 22:36:35 +01:00
Ben Johnson a5ccf5ce9a
fix(tsdb): Fix series file count
Previously the series file did not include tombstones in the total
count. This commit now includes tombstones in the count as well as
fixes an issue where replayed tombstone records could exist but
their underlying ID did not exist. This caused the count to become
negative and with the count being `uint64` it caused the count to
rollover to `math.Uint64Max`.
2019-05-03 09:58:13 -06:00
Jeff Wendling ef0768db31
tsm1: predicate deletes (#13371)
tsm1: predicate deletes
2019-05-03 14:27:25 +00:00
Stuart Carnie bf774b66ce
fix(storage): Ensure Tag(Keys|Values) APIs never return (nil, nil)
Formalized this post condition in the documentation and added additional
unit tests.

Added a nil guard and unit test to WriteStringIterator.
2019-05-02 09:45:38 -07:00
Jeff Wendling 16e9eb4cb9 tsdb: respond to feedback and improve test coverage
predicate.go:
	UnmarshalPredicate       100.0%
	NewProtobufPredicate     100.0%
	Matches                  100.0%
	Marshal                  100.0%
	walkPredicateNodes       100.0%
	buildPredicateNode       100.0%
	newPredicateState        100.0%
	Reset                    100.0%
	Set                      100.0%
	newPredicateCache        100.0%
	Cached                   100.0%
	Store                    100.0%
	Update                   100.0%
	Update                   92.9%
	Update                   94.1%
	predicateEval            90.9%
	predicatePopTag          100.0%
	predicatePopTagEscape    100.0%
2019-05-01 13:40:40 -06:00
Jeff Wendling 4b4a814d7d storage: fix predicate matching on field tags 2019-05-01 13:40:40 -06:00
Jeff Wendling 740d669514 tsm1: teach the cache about predicates 2019-05-01 13:40:40 -06:00
Jeff Wendling 4fb7bf1730 tsm1: implement predicate matcher from protobufs 2019-05-01 13:40:40 -06:00
Jeff Wendling 4096f93891 tsm1: implement reading and writing predicates in tombstone files 2019-05-01 13:40:40 -06:00
Jeff Wendling dcf797f111 tsm1: basic predicate implementation at index layer
Only wires it up. No tests, no tombstone tracking, nothing.
2019-05-01 13:40:40 -06:00
Jeff Wendling 7403fd8aa9 tsm1: rename engine method to DeletePrefixRange
The storage/engine knows about buckets, but the tsm1/engine doesn't, so
name the tsm1/engine method Prefix and keep the storage/engine named
Bucket.
2019-05-01 13:40:40 -06:00
Jacob Marble 8c269e0153
chore(log): Put trace_id back in logs (#13712)
* chore(log): Put trace_id back in logs

* fix tests
2019-04-30 18:51:22 -07:00
Stuart Carnie 65e4e3c5de
Merge pull request #13701 from influxdata/sgc/bp/2.x/13687
Don't panic when encoding string blocks and length of source slice is too large
2019-04-30 10:02:40 -07:00
Stuart Carnie 369a4610e6
fix(storage): Don't panic when length of source slice is too large
StringArrayEncodeAll will panic if the total length of strings
contained in the src slice is > 0xffffffff. This change adds a unit
test to replicate the issue and an associated fix to return an error.

This also raises an issue that compactions will be unable to make
progress under the following condition:

* multiple string blocks are to be merged to a single block and
* the total length of all strings exceeds the maximum block size that
  snappy will encode (0xffffffff)

The observable effect of this is errors in the logs indicating a
compaction failure.

Fixes #13687
2019-04-29 13:29:41 -07:00
Jeff Wendling 9cd7c0f7e3 tsi1: don't do verbose debug logging unless test fails 2019-04-29 14:01:45 -06:00
Stuart Carnie 7b97a41dcb
feat(storage): Teach TagKeys, TagValues how to accumulate statistics
This commit teaches the storage schema APIs how to track statistics
and make them available via the returned `cursors.StringIterator`.

Statistics are only tracked when decoding TSM blocks or when scanning
the in-memory cache.

Closes #13541
2019-04-24 11:14:22 -07:00
Stuart Carnie ed344d25f8
feat(storage): Teach storage how to find a distinct set of tag keys
The TagValues API will perform a linear scan if there is no predicate;
otherwise, it will use the index to find a list of candidate series
keys.

TagKeys expects the predicate to be transformed such that
`_measurement` and `_field` are remapped to `\x00` and `\xff`
respectively.

There is one TODO marked to analyze the predicate for a
`\x00 = '<measurement>'` pattern. If found, the predicate can be
eliminated and fall back to a linear prefix scan by combining the org,
bucket and measurement. This is tracked by issue #13497.
2019-04-24 11:14:22 -07:00
Ben Johnson 272f340c30
Merge point parse & explode. 2019-04-24 10:12:15 -06:00
Jeff Wendling 59279837e5 tsi1: partition close deadlock
When a tsi1 partition closes, it waits on the wait group for compactions
and then acquires the lock. Unfortunately, a compaction may start in the
mean time, holding on to some resources. Then, close will attempt to
close those resources while holding the lock. That will block until
the compaction has finished, but it also needs to acquire the lock
in order to finish, leading to deadlock.

One cannot just move the wait group wait into the lock because, once
again, the compaction must acquire the lock before finishing. Compaction
can't finish before acquiring the lock because then it might be operating
on an invalid resource.

This change splits the locks into two: one to protect just against
concurrent Open and Close calls, and one to protect all of the other
state. We then just close the partition, acquire the lock, then free
the resources. Starting a compaction requires acquiring a resource
to the partition itself, so that it can't start one after it has
started closing.

This change also introduces a cancellation channel into a reference
to a resource that is closed when the resource is being closed, allowing
processes that have acquired a reference to clean up quicker if someone
is trying to close the resource.
2019-04-22 09:06:32 -06:00
Tanya Gordeeva 97572ee878 feat(storage): add tsm level metrics
Adds prometheus metrics recording compaction levels for TSM files.
2019-04-19 13:33:52 -07:00
Stuart Carnie d5341a1a4a
feedback: Fix comments in template 2019-04-18 16:19:19 -07:00
Stuart Carnie 972cda1775
feedback: Changes in response to PR feedback 2019-04-18 16:19:18 -07:00
Stuart Carnie 904c91aecc
chore: Fix staticcheck complaints 2019-04-18 16:19:18 -07:00
Stuart Carnie d3790aa072
feat: Teach storage engine how to find tag values for a given key
The TagValues API will perform a linear scan if there is no predicate;
otherwise, it will use the index to find a list of candidate series
keys.

TagValues expects the predicate to be transformed such that
`_measurement` and `_field` are remapped to `\x00` and `\xff`
respectively.

There is one TODO marked to analyze the predicate for a
`\x00 = '<measurement>'` pattern. If found, the predicate can be
eliminated and fall back to a linear prefix scan by combining the org,
bucket and measurement.
2019-04-18 16:19:18 -07:00
Stuart Carnie 35e0094a28
feat: TimeRangeIterator for checking if keys have data in a TSM file
The TimeRangeIterator permits linear or random index scans and
can answer whether the current key has data for the specified time
interval, considering any tombstones.

When there are no tombstones there are some opportunities for
optimization to skip decoding blocks. Specifically, if the
queried time interval overlaps any boundaries of the TSM index entries.
2019-04-18 16:19:18 -07:00
Stuart Carnie 7544ea0a5b
feat: Teach Values how to determine it contains data for a time interval
Add a Contains API which is a peer to the TimestampArray.Contains
function. This is used by the schema APIs to determine if data exists
in the cache for a given key and time interval.
2019-04-18 16:19:18 -07:00
Stuart Carnie 1ddd0445d8
feat(tsm1): Add Seek API to TSMIndexIterator
Permits random access of the iterator, correctly maintaining state,
so that Next may be called to iterator from a given key.

This API will be used by the schema APIs when a predicate is specified,
typically requiring random access.
2019-04-18 16:19:18 -07:00
Stuart Carnie 36a33bcb9f
feat(tsdb): Teach storage how to only decode timestamps from a block
TimestampArray.Contains(min,max) API performs a binary search to
determine if timestamps exist for the given time interval.

It also implements Exclude to drop timestamps that have been tombstoned.

DecodeTimestampArrayBlock decodes only the timestamps of the provided
block.
2019-04-18 16:19:18 -07:00
Stuart Carnie 7fc9661b7b
chore: Move StringIterator to cursors package for wider reuse 2019-04-18 16:19:17 -07:00
Stuart Carnie e74f2f8e08
chore(cursors): Remove unused field 2019-04-18 16:19:17 -07:00
Stuart Carnie d67b1ef245
fix(cursors): Add go:generate directive 2019-04-18 16:19:17 -07:00
Todd Persen 138c17f22c Fix typos in tsdb package 2019-04-17 12:55:38 -07:00
Ben Johnson 2b3ce82852
fix(tsdb): Remove TSI stats file cache
Removes the `STATS` file generated during TSI compaction as it had
potential for becoming inconsistent with the index data. Instead,
stats are recalculated on start up and on each compaction on a
per-partition basis.

Computing stats for 10M series across 10K measurements takes
approximately 0.171s.
2019-04-17 09:34:32 -06:00
Jacob Marble f56c42794b
chore(tracing): Cleanup (#13296)
* chore(tracing): Cleanup

* broken test

* fix unused var

* fix test
2019-04-10 19:28:21 -07:00