Commit Graph

2533 Commits (772a44eddf8535d2b8de99a6a977dab7a8d7c7cb)

Author SHA1 Message Date
Ben Johnson 58aed93fe6
Add option for unicode validation. 2018-05-02 11:16:55 -06:00
Jonathan A. Sternberg 6607c29a02
Merge pull request #9649 from influxdata/js-eval-functions-in-where
Allow math functions to be used in the condition
2018-05-02 08:29:08 -05:00
Jason Wilder aea9bf3464 Hide series type map behind feature flag
The performance is not good enough to enable by default so this
allows the functionality to be merged while performance is improved.
2018-05-02 06:50:35 -06:00
Jonathan A. Sternberg 10ed277e7a
Merge pull request #9791 from influxdata/js-spread-stream-function
Optimize the spread function to process points iteratively instead of in batch
2018-05-01 15:08:34 -05:00
Jason Wilder ec3f5c353c Fix panic in FileStore.walkKeys
If a TSM file is replaced while walkKeys is running, a panic could
occur because the mmap has been unmapped.
2018-04-30 17:26:23 -06:00
Jason Wilder 2be2418b89 Add series type validation to Engine
This is the start of per-series validation that occurs in the
Engine write path.  It uses an in-memory radix tree to reduce
memory usage and is re-built on demand the first time a series
is written.
2018-04-30 17:26:23 -06:00
Ben Johnson f459d87325
Merge pull request #9785 from influxdata/rename-bad-tsm-file
Rename & log corrupt tsm files on load
2018-04-30 15:37:45 -06:00
Jacob Marble 63b9c98187 fix tests by closing iterators and cursors 2018-04-30 13:46:03 -07:00
Jacob Marble 7de2dcd3d9 TSM: TSMReader.Close blocks until reads complete 2018-04-30 13:46:03 -07:00
Jacob Marble fa24142467 tsdb/indx/inmem: Fix megacheck issue 2018-04-30 10:25:07 -07:00
Jonathan A. Sternberg 9d049c4b62 Optimize the spread function to process points iteratively instead of in batch 2018-04-30 11:25:29 -05:00
Stuart Carnie e0ae9c5a2d tsm1: Replace goroutine `merge` with k-way merge
Previously replaced WalkKeys implementation for a considerable
improvement to startup time
2018-04-30 07:57:55 -07:00
Ben Johnson 108fa09439
Rename corrupt tsm files on load. 2018-04-27 14:27:44 -06:00
Jacob Marble b23e32321c Remove unused code in tsdb/index/inmem 2018-04-26 13:19:01 -07:00
Jacob Marble 4282bf2744 Remove unused function parameter 2018-04-26 13:19:01 -07:00
Edd Robinson ba16268f41
Merge pull request #9777 from influxdata/er-index-log
Log information about index version during startup
2018-04-26 10:48:54 +01:00
Jeff Wendling c38108eb8a fix some megacheck errors 2018-04-25 18:14:25 -06:00
Jeff Wendling 9f09a3c1c2 add tests for verify_seriesfile
does some basic sanity checks. it's hard to be more exhaustive without
either taking a crazy amount of time, or being non-deterministic,
but at least this makes sure we barf in some cases.
2018-04-25 18:10:19 -06:00
Jeff Wendling e771040a7d Add verify-seriesfile to influx_inspect
Fixes #9767
2018-04-25 18:10:17 -06:00
Jeff d21365d804
Merge pull request #9762 from influxdata/jmw-abstract-measurement-validation
Add FieldValidator to allow custom validations on measurements

Fixes #9745.
2018-04-25 10:23:37 -06:00
Jacob Marble 1c63c4a3da Fix tsdb/index/inmem benchmark tests 2018-04-25 08:51:28 -07:00
Jeff Wendling e5dbc18d0b remove bool return param from dataTypeFromModelsFieldType 2018-04-25 09:48:24 -06:00
Edd Robinson 0b4a403679 Provide warning when mixed index used on db 2018-04-25 13:57:08 +01:00
Edd Robinson 32e195860b Log index type when opening shard 2018-04-25 13:02:09 +01:00
Jeff Wendling 29a62e4f74 Add FieldValidator to allow custom validations on measurements
No appreciable changes in benchmark results. It seems like this
function is less than 4% of cpu time in the write workloads in the
benchmarks at least.
2018-04-23 20:21:27 -06:00
Jeff Wendling d55979450a Fix shard benchmarks
at some point, the Inmem field on the engine options became
required, but the benchmarks weren't updated.

also uses filepath everywhere when manipulating file paths.
2018-04-23 12:39:24 -06:00
Ben Johnson dbbe9d8467
Merge pull request #9615 from influxdata/bj-check-shard-count-on-series-iterator-master
Remove error for series file when no shards exist
2018-04-20 08:14:24 -06:00
Stuart Carnie 14dcc5d6e7 PR feedback 2018-04-19 18:05:55 -07:00
Stuart Carnie e7389b18c0 tsdb: add additional engine options
* filters allow specific combinations of database, retention policy and
  shard groups to be opened. This was added to reduce the start-up time
  of the export tool and limit the memory usage.
2018-04-19 18:05:55 -07:00
Stuart Carnie 7ebfc9c544 add default to avoid blocking 2018-04-12 15:42:33 -07:00
Jacob Marble 10a7ffb647
Check for errors from binary.Uvarint when reading TSI logs (#9705)
* Check for errors from binary.Uvarint when reading TSI logs

* also check len(parsed) == len(input)

* wrap binary.Uvarint

* make uvarint() more generally useful/used
2018-04-12 09:59:56 -07:00
Jonathan A. Sternberg 1f9227e20c Allow math functions to be used in the condition 2018-04-10 10:55:34 -05:00
Jason Wilder 97ecf62ffb Return time range from delete predicate func
This moves the time range to delete to be returned by the predicate
func in DeleteSeriesRangeWithPredicate.  It allows for a single delete
to delete different ranges of times per series instead of a single
range of time for all series.
2018-04-09 20:01:33 -06:00
Jonathan A. Sternberg bf0eb140ec
Merge pull request #9686 from influxdata/js-tsm1-aggregate-benchmarks
Adding additional aggregate benchmarks for tsm1
2018-04-09 11:08:57 -05:00
Jonathan A. Sternberg 117aac4b9e Adding additional aggregate benchmarks for tsm1
This will help us address performance problems in the underlying tsm1
implementations of the aggregate iterators.
2018-04-09 10:37:33 -05:00
Jason Wilder 8cc2e68d3b Fix panic in readTombstoneV4
The length check was backwards so if a series key was longer than
4096 bytes, it would cause a slice out of bounds panic.
2018-04-05 22:15:54 -07:00
Adam 72bceca888
Fix stream package to allow for renaming the file before writing it to the stream (#9684)
* Fix stream package to allow for renaming the file before writing it to the stream

* updated test to make sure that the final tsm file has more than one block
2018-04-05 16:24:29 -04:00
Ben Johnson 92d38414f2
Add adjustable TSI log file size.
This commit adds the `max-index-log-file-size` configuration flag so
that users can restrict the maximum size of log files before compaction.
The default limit was also lowered from `5MB` to `1MB`. The original
size was set before we partitioned the index so the change reflects this.
2018-04-02 11:47:59 -06:00
Mark Rushakoff b3c2d9290f Log error encountered when reading WAL files
Inspired by #9657.
2018-03-30 09:40:58 -07:00
Ben Johnson db9d32e514
Ignore index size in Engine.DiskSize().
TSM includes index in DiskSize(), however, indexes are not copied
and shouldn't be included in this method. This causes issues with
`copy-shard`.
2018-03-29 13:03:48 -06:00
Jacob Marble 470ee7f176 Add ability to delete many series with predicate 2018-03-28 08:32:18 -07:00
Stuart Carnie 2cc1f5137e support for tenant+bucket
NOTE: to match storage service, values for database and rp are
hard-coded to `db` and `rp` respectively
2018-03-23 12:26:55 -07:00
Jason Wilder 477de23e35
Merge pull request #9609 from influxdata/jw-compaction-filter
Add capability change compaction planner
2018-03-22 07:30:52 -06:00
Jason Wilder 0eb6564e79 Add extension point to swap out the compaction planner 2018-03-21 15:51:00 -06:00
Stuart Carnie aa61359cc7 Storage RPC API improvements. See PR for details
* reduce # allocations (115M -> 22M)
* reduce size allocations (53GB -> 1.3GB)
* reduce RPC query time (45s -> 12.9s)
2018-03-21 13:46:09 -07:00
Ben Johnson da8669f3e2
Remove error for series file when no shards exist 2018-03-21 14:41:11 -06:00
Ben Johnson 2a8ca9a10e
Revert "Use MADV_WILLNEED when loading TSM files"
This reverts commit ee270e1dd2.
2018-03-21 13:26:45 -06:00
Jonathan A. Sternberg f8d60a881d Refactor the math engine to compile the query and use eval
This change makes it so that we simplify the math engine so it doesn't
use a complicated set of nested iterators. That way, we have to change
math in one fewer place.

It also greatly simplifies the query engine as now we can create the
necessary iterators, join them by time, name, and tags, and then use the
cursor interface to read them and use eval to compute the result. It
makes it so the auxiliary iterators and all of their complexity can be
removed.

This also makes use of the new eval functionality that was recently
added to the influxql package.

No math functions have been added, but the scaffolding has been included
so things like trigonometry functions are just a single commit away.

This also introduces a small breaking change. Because of the call
optimization, it is now possible to use the same selector multiple times
as a selector. So if you do this:

    SELECT max(value) * 2, max(value) / 2 FROM cpu

This will now return the timestamp of the max value rather than zero
since this query is considered to have only a single selector rather
than multiple separate selectors. If any aspect of the selector is
different, such as different selector functions or different arguments,
it will consider the selectors to be aggregates like the old behavior.
2018-03-19 15:01:15 -05:00
Mark Rushakoff a65e51e295
Merge pull request #9588 from influxdata/mr-math-bits
Use math/bits exclusively instead of go-bits
2018-03-15 14:29:55 -07:00
Ben Johnson 5bd29a03de
Merge pull request #9586 from influxdata/bj-interrupt-show-series
Allow SHOW SERIES kill
2018-03-15 14:35:46 -06:00
Mark Rushakoff 426a9a0b8b Use math/bits exclusively instead of go-bits
We won't be rolling back to pre-Go1.9, so prefer the standard library
over a dependency that provides backwards compatibility.
2018-03-15 12:03:24 -07:00
Edd Robinson 8ab8b5a428
Merge pull request #9580 from influxdata/er-wal-race
Fix data race in WAL
2018-03-15 17:59:55 +00:00
Ben Johnson f6fdba2590
Allow SHOW SERIES kill. 2018-03-15 11:22:34 -06:00
Stuart Carnie 6cf6ae7af4 Use combined IndexSet when executing meta queries
* removed unused fieldset field
2018-03-15 09:59:11 -07:00
Edd Robinson 0fc7643d59 Fix data race in WAL
This commit fixes a data race in the WAL, which can occur when writes
and deletes are being executed concurrently. The WAL uses a buffer pool
of `[]byte` when reading the WAL. WAL entries are unmarshaled into these
buffers and passed along to the relevant methods handling the different
types of entry (write, delete etc).

In the case of deletes, the keys that need to be deleted were being
stored for later processing, however these keys were part of the backing
array of initial buffer from the pool. As such, those keys could be
written to at a future time when handling other parts of the WAL.
2018-03-15 12:51:30 +00:00
Jason Wilder 0c630a3cb5
Merge pull request #9461 from CAFxX/patch-2
Do not drop on the floor small buffers
2018-03-12 16:55:34 -06:00
Edd Robinson 7c3ae91d1e
Merge pull request #9551 from influxdata/er-fieldset-panic
Fix panic when checking fieldsets
2018-03-12 17:28:58 +00:00
Jason Wilder 444ad747b6 Add option to disable WAL
This adds an internal option (not exposed via config) to disable the WAL
when using the TSM engine directly.
2018-03-12 09:48:11 -06:00
Edd Robinson ec93b0eb0c Ensure all shards checked for fields within an IndexSet 2018-03-12 15:25:45 +00:00
Edd Robinson c1e1412dae Don't panic when checking for field 2018-03-12 15:25:20 +00:00
Edd Robinson ac0c0756bf Alter test to trigger panic 2018-03-12 13:07:08 +00:00
Jonathan A. Sternberg a6741aaf6c Simplify tsi1/log_file.go according to megacheck 2018-03-09 11:00:46 -06:00
Ben Johnson d0688201ba
Fix missing Store.Close() unlock. 2018-03-06 10:36:44 -07:00
Ben Johnson 8e62e8d3bd
Fix TSI log file recovery. 2018-03-05 14:49:12 -07:00
Ben Johnson fb3187f62f
Merge pull request #9496 from influxdata/bj-fix-series-key-replay-after-delete
Fix panic on tsi1 log replay of deleted series.
2018-02-28 08:37:07 -07:00
Jonathan A. Sternberg 87ac8ad385
Merge pull request #9491 from influxdata/js-9290-index-boolean-literals
Evaluate a true boolean literal when calculating tag sets
2018-02-28 09:14:24 -06:00
Ben Johnson 567a35d364
Fix panic on tsi1 log replay of deleted series. 2018-02-28 08:06:30 -07:00
Jonathan A. Sternberg 6baf354818 Evaluate a true boolean literal when calculating tag sets 2018-02-28 08:08:21 -06:00
Edd Robinson 3086f02b2e
Merge pull request #9490 from influxdata/er-time-test
Support less granular mtime in LastModified test
2018-02-28 10:14:39 +00:00
Jason Wilder 4eaae6111e
Merge pull request #9494 from influxdata/jw-tagsets-contains
Skip creating cursors for series not in a shard
2018-02-27 21:47:49 -07:00
Stuart Carnie 3547331f54
Merge pull request #9495 from influxdata/sgc-logging
use child logger
2018-02-27 21:41:14 -07:00
Jason Wilder 2896d210af Skip creating cursors for series not in a shard
There was a check in inmem TagSets to see if a series was assigned
to a shard to prevent cursors for non-existent series getting created.
This check was lost during TSI development because inmem Series tracking
was removed and then replaced with bitsets.  The bitsets were not
re-incorporated as before.  This adds the functionality back using
the bitsets.
2018-02-27 21:23:59 -07:00
Stuart Carnie e493a3e1db use child logger 2018-02-27 20:27:24 -07:00
Ben Johnson fee6149791
Merge pull request #9489 from influxdata/bj-dumptsi-cardinality
Add dumptsi path error handling.
2018-02-27 09:15:03 -07:00
Edd Robinson 45af822200 Support less granular mtime 2018-02-27 16:12:59 +00:00
Stuart Carnie 48fb2a4cc5
Merge pull request #9487 from influxdata/sgc-tagsets
fallback to inmem TagSets implementation
2018-02-27 09:06:54 -07:00
Ben Johnson b3fcc63a78
Add dumptsi path error handling. 2018-02-27 08:30:12 -07:00
Stuart Carnie b72e0c5941 fallback to inmem TagSets implementation 2018-02-27 07:49:51 -07:00
Edd Robinson 96c0ecf618 Improve startup time of `inmem` index
This commit improves the startup time when using the `inmem` index by
ensuring that the series are created in the index and series file in
batches of 10000, rather than individually.

Fixes #9486.
2018-02-27 13:33:00 +00:00
Stuart Carnie b03cf6a953 prefix with `tsm1_` for consistency 2018-02-26 13:00:03 -07:00
Stuart Carnie a74d296200 use underscore vs period, fix doc comment, add database name to CQ 2018-02-26 10:08:43 -07:00
Stuart Carnie d40d3ecc2e
Merge pull request #9456 from influxdata/sgc-logging
Generate trace logs for a number of important InfluxDB operations
2018-02-21 15:09:18 -07:00
Stuart Carnie d135aecf02 Generate trace logs for a number of significant influx operations
* tsdb Store.Open traces all events related to opening files
    * op.name : tsdb.open
* retention policy shard deletions
    * op.name : retention.delete_check
* all TSM compaction strategies
    * op.name : tsm1.compact_group
* series file compactions
    * op.name : series_partition.compaction
* continuous query execution (if logging enabled)
    * op.name : continuous_querier.execute
* TSI log file compaction
    * op_name: index.tsi.compact_log_file
* TSI level compaction
    * op.name: index.tsi.compact_to_level
2018-02-21 15:08:49 -07:00
Jason Wilder fd90ec2b04 Remove noisy trace logging in TSM engine
This logging is noisy and allocates a lot of garbage.  There are
stats now that have the same information.
2018-02-21 12:51:01 -07:00
Jason Wilder a865e14455
Merge pull request #9470 from influxdata/jw-cur-close
Make closing TSM cursors idempotent
2018-02-21 09:34:13 -07:00
Jason Wilder fca3061f3c Make closing TSM cursors idempotent
Double closing a bufCursor would cause a panic.  There was also
some typed cursors that had the same problem.
2018-02-21 09:05:54 -07:00
Jonathan A. Sternberg d38413a849
Merge pull request #9454 from influxdata/js-structured-logging
Update logging calls to take advantage of structured logging
2018-02-21 09:14:40 -06:00
Ben Johnson 2bc9e10757
Merge pull request #9465 from influxdata/js-write-to-shard-during-delete
Mark a shard as in process of being deleted
2018-02-20 15:01:36 -07:00
Jason Wilder f7279b57f3 Re-open last WAL segment
Re-open the last wal segment instead of creating a new one.  This fixes
an issue where the last modified time of the WAL would change on
restart.  It also avoids a lot of IO file churn on restart.
2018-02-20 14:24:04 -07:00
Jonathan A. Sternberg 0727ffbf4e
Mark a shard as in process of being deleted
Without this, deleting a shard could trigger things so that a write
would attempt to create the shard again before it was actually deleted.
2018-02-20 12:17:30 -07:00
Jonathan A. Sternberg 2bbd96768d Update logging calls to take advantage of structured logging
Includes a style guide that details the basics of how to log.
2018-02-20 10:04:19 -06:00
Carlo Alberto Ferraris 228e17d79b
Do not drop on the floor small buffers
Currently if a buffer from the buffer is too small to satisfy its request then we simply drop it and allocate a new one.

This change puts it back in the pool and then allocates a new one.
2018-02-17 20:41:07 +09:00
Jason Wilder 387df59847
Merge pull request #9451 from influxdata/jw-inmem
Inmem series creation improvements
2018-02-15 11:51:53 -07:00
Edd Robinson 736eb28551
Merge pull request #9450 from influxdata/er-sketch-race
Fix data race when collecting sketches
2018-02-15 18:48:37 +00:00
Jason Wilder eeb0b967f9 Don't create series one at a time when limits in place
When a max series per data limit was in place (or 0), we would create
series one at a time which really affects throughput.  This does it
in bulk which is less accurate, but more performant.
2018-02-15 10:43:39 -07:00
Jason Wilder cadb3adea0 Increase SeriesSegment write buffer size
The batch of writes is almost always larger than the 4096 default
which leads to more write IOs.  Increasing to 32k allows the majority
of writes to be handled in one IO.
2018-02-15 10:17:34 -07:00
Jason Wilder 67e65e50ff Remove inmem lastModified time
This was added for preventing concurrent writes and deletes to the
same series.  This is not handled by the bitsets for both tsi and
inmme.  The time.Now() calls shows up in profiles and is not needed.
2018-02-15 09:29:52 -07:00
Edd Robinson 433e643364 Fix data race when collecting sketches 2018-02-15 11:16:32 +00:00
Stuart Carnie 6e47ff8d7f simplify code 2018-02-14 06:55:48 -07:00
Edd Robinson e5c8fd9dc5 Ensure nil sketches never returned 2018-02-09 15:29:42 +00:00
Ben Johnson ed9c0576d4
Add series sketches, fix tombstones in index files. 2018-02-07 14:52:13 -07:00
Edd Robinson 0d164f3164
WIP - tsi integration sketches 2018-02-07 14:52:13 -07:00
Edd Robinson 64171229e8
Add test for index sketches 2018-02-07 14:52:13 -07:00
Edd Robinson 7a55735562
Add option to set LogFile compaction size 2018-02-07 14:52:13 -07:00
Edd Robinson 544329380f
Add empty series sketches back to tsi1 index
This commit adds initial empty sketches back to the tsi1 index, as well
as ensuring that ephemeral sketches in the index `LogFile` are updated
accordingly.

The commit also adds a test that verifies that the merged sketches at
the store level produce the correct results under writes, deletions and
re-opening of the store.

This commit does not provide working sketches for post-compaction on the
tsi1 index.
2018-02-07 14:52:13 -07:00
Edd Robinson c8f30da88a
Tidy up tests 2018-02-07 14:52:13 -07:00
Stuart Carnie a058d204d8 remove redundant closing channel 2018-02-06 12:08:58 -07:00
Ben Johnson b09f35056f
Verify series key after lookup.
Because of a race between the index and series file lookups, empty
keys can be returned for series which are tombstoned after the
series ids are obtained but before the caller looks up the key.
2018-02-02 13:26:05 -07:00
Stuart Carnie 0f6e6fb9ef
Merge pull request #9192 from influxdata/sgc-writer
ensure tsmWriter#Write returns ErrMaxBlocksExceeded
2018-02-01 15:39:01 -07:00
Jason Wilder 3299e549aa Increase WAL write buffer size
The default of 4096 results in writes to the WAL still requiring muliple
IOs.  We had previously bumped this to 1M, but that was too high when
there are many shards.  Increasing to around 16k reduces the IOs to
one or two for the workloads tested.  We may want to make this
configurable in the future.
2018-01-31 13:55:32 -07:00
Jason Wilder e9db11a3e9 Reduce cache partitions to 16
The large number of partitions cause big HeapInUse swings at higher
cardinality which can lead to OOMs.  Reducing this to 16 lowers
write throughput to some extent at lower cardinalities, keeps memory
more stable over the long run.
2018-01-31 13:55:32 -07:00
Jason Wilder ee270e1dd2 Use MADV_WILLNEED when loading TSM files
When the TSM index is large, this hints to the kernel to start
faulting in pages to avoid lots of smaller page faults.
2018-01-31 12:38:16 -07:00
Jason Wilder 20d429c62b Use cached tags when applying series entries 2018-01-30 16:02:50 -07:00
Ben Johnson da8568d86c
Remove unused field. 2018-01-30 10:34:29 -07:00
Ben Johnson a6d11585b3
Add TSI compaction interruption. 2018-01-30 10:34:17 -07:00
Ben Johnson 0652effb78
Interrupt TSI & Series File Compactions 2018-01-30 10:34:17 -07:00
Joe LeGasse 9f757290f8
Merge pull request #9335 from influxdata/jl-race
Prevent race condition caused by WaitGroup re-use
2018-01-29 16:30:45 -05:00
Joe LeGasse 21a58235fc
Merge branch 'master' into jl-race 2018-01-29 15:52:18 -05:00
Edd Robinson b19edd55ac Ensure shard-level cardinality is correct 2018-01-29 16:22:42 +00:00
Edd Robinson ef5e3a09cd Tidy up test initialisation 2018-01-29 15:01:31 +00:00
Edd Robinson 7931c78e2b Further simplifications 2018-01-23 06:57:51 -08:00
Edd Robinson 821b784fa0 Switch deprecated HasPrefix for raw string check 2018-01-21 12:08:25 -08:00
Edd Robinson 42c3adeffc simplify packages under tsdb 2018-01-21 09:41:27 -08:00
Edd Robinson 4ccb6ada69 Remove unused code/cleanup tsdb package 2018-01-20 14:06:15 +00:00
Edd Robinson 90903fa6ed Remove unused code/cleanup engine package 2018-01-20 13:56:45 +00:00
Edd Robinson 030fdc7966 Remove unused code/cleanup index packages 2018-01-20 13:56:28 +00:00
Jason Wilder 97f61e0ff4 Allow SeriesFile compaction to be disabled 2018-01-18 15:54:52 -07:00
Jason Wilder d755daede8 Add ability to enable/disable tsi compactions 2018-01-18 14:25:58 -07:00
Jason Wilder a88ac031de Fix MeasurementHasSeries returning incorrect value
If all the series in a measurement were tombstone, MeasurementHasSeries
would return true because the ok var was re-used from a prior check
earlier in the func.  This caused it to be true all the time unless
the measurment was actually tombstoned.
2018-01-18 13:05:04 -07:00
Jason Wilder 28edf1392a Use full 32bits for series IDs
This reworks the series ID allocation to prevent an overflow issue.
2018-01-18 09:45:36 -07:00
Edd Robinson 2bf6ea3306
Merge pull request #9334 from influxdata/jw-delete-deadlock
Fix deadlock in DeleteSeries
2018-01-17 18:46:04 +00:00
Joe LeGasse 425a5e5f17 tsm1: prevent WaitGroup race 2018-01-17 13:08:11 -05:00
Jason Wilder 8f52e442e6 Fix deadlock in DeleteSeries
The Store.Delete series held an RLock while deleting from each shard.
While deleting, the Engine uses shardSet to see if a series is fully
deleted.  The shardSet.ForEach also takes and RLock.  If a Lock is
requested between these two calls, a deadlock occurs.

To fix, we don't need to hold an RLock for the duration of the delete
in the store as each Shard handles concurrency itself and we have a
snapshot of the shards we need to access.
2018-01-17 10:28:21 -07:00
Joe LeGasse 140d5c3efa
Merge pull request #9327 from influxdata/jl-wal-lastmodified
wal: update lastWriteTime behavior
2018-01-17 11:54:33 -05:00
Joe LeGasse 129c2f0120 tsm: skipping LastModified test for now 2018-01-17 11:14:45 -05:00
Jason Wilder 2d4790b9f7
Merge pull request #9328 from influxdata/jw-delete-tsi-perf
Speed up deletes for tsi
2018-01-17 08:31:47 -07:00
Jason Wilder b05754fd23 Fix nil pointer panic
Under concurrent writes and deletes of the same series, a nil panic
could occur in bytes.Compare.  Instead of setting the seriesKeys to
nil, set them to an 0 length slice which prevents the panic.
2018-01-17 07:57:30 -07:00
Jason Wilder 5d6b8fc834 Drop measurement after series
This separates out the dropping of a measurement from the series
to avoid frequent checks to see if a measurement still has series.
The series are dropped individually and we keep track of which
measurements are involved and then delete each measurment afterwards.
2018-01-17 07:57:25 -07:00
Edd Robinson de0e9b1a4b Unify approach to short-circuit auth 2018-01-17 14:00:24 +00:00
Jason Wilder 02da1d6dfa Remove defer for SeriesIDSet.Contains
This showed up in profiles deleting high cardinality.
2018-01-16 20:46:45 -07:00
Joe LeGasse 68e20c4f80 wal: update lastWriteTime behavior 2018-01-16 21:22:24 -05:00
Ben Johnson b36b9f109f
Merge pull request #9324 from influxdata/bj-tsi-log-entry-short-buffer
Fix LogEntry.UnmarshalBinary() short buffer check.
2018-01-16 18:42:09 -07:00
Jason Wilder 5f45208752
Merge pull request #9326 from influxdata/er-series-cardinality
Use bitsets to calculate series cardinality
2018-01-16 16:53:55 -07:00
Edd Robinson bd762380b0 Use bitsets to calculate series cardinality 2018-01-16 23:22:52 +00:00
Ben Johnson 960b6f8ba5
Merge pull request #9325 from influxdata/bj-tsi-partition-close-check
Add tsi1.Partition closing check before compaction.
2018-01-16 16:19:36 -07:00
Ben Johnson 3937fed7a1
Add tsi1.Partition closing check before compaction. 2018-01-16 13:32:44 -07:00
Ben Johnson 5f9d53b586
Fix LogEntry.UnmarshalBinary() short buffer check. 2018-01-16 13:14:26 -07:00
Jason Wilder 1c8676b4a3 Rebuild corrupted fields index when necessary
If the fields.idx was corrupted in someway, it would cause the shard
to fail to load.  Deleting the file will allow it to be rebuilt.

This change handles this automatically so it's rebuilt if necessary
without user intervention.
2018-01-16 11:31:07 -07:00
Edd Robinson ceb3abd118 Remove series when shard rolls over
Series should only be removed from the series file when they're no
longer present in any shard. This commit ensures that during a shard
rollover, the series local to the shard are checked against all other
series in the database.

Series that are no longer present in any other shards' bitsets, are then
marked as deleted in the series file.
2018-01-16 15:58:20 +00:00
Edd Robinson 338f284bc9 Simplify series set Merge logic 2018-01-16 14:56:54 +00:00
Edd Robinson e902998f4e All closes are now fast 2018-01-16 14:56:54 +00:00
Edd Robinson d890f29fcb Remove redundant index methods
Now that each shard-local index is maintaining a bitset of series ids,
tracking the series present in the local shard's tsm engine, there is no
need to track shards in the `inmem` index.

This commit removes the methods associated with tracking those
series/shard relationships.
2018-01-16 14:56:54 +00:00
Edd Robinson 8039165ab4 Ensure no double r-locking occurs in IndexSet
use. However, because the reference counting was implemented via
mutexes, it was possible to double `RLock` the series file mutex. This
allows a `Lock` to arrive in-between the two `RLock`s, (such as when
deleting the database), causing deadlock.

This commit addresses this by ensuring that from within `IndexSet`
methods, when calling other `IndexSet` methods, that they're all
unexported, and that those unexported methods never take a lock on the
series file.

Keeping series file locking in exported `IndexSet` methods only, allows
one to see any future races more easily.
2018-01-16 14:56:34 +00:00
Ben Johnson e1aff89299
Fix data race. 2018-01-15 11:53:49 -07:00
Ben Johnson d0429dc582
Batch insert series for inmem index. 2018-01-15 11:13:59 -07:00
Ben Johnson cc30abcae6
Fix TSI MeasurementExists() test. 2018-01-15 08:28:53 -07:00
Edd Robinson ee8d9e41f0 Update test with new DELETE method format 2018-01-15 13:27:05 +00:00
Edd Robinson a2ece0a49a Pass series id in via Index API 2018-01-15 12:00:31 +00:00
Ben Johnson 47851f4b7d Fix tag value auth check iterator. 2018-01-15 12:00:31 +00:00
Ben Johnson d295f30686 Remove series id check during deletion. 2018-01-15 12:00:31 +00:00
Ben Johnson 1c4ab05c7e Add fast TSI MeasurementHasSeries() check. 2018-01-15 12:00:30 +00:00
Ben Johnson b07e41fa7f Fix partition series set building. 2018-01-15 12:00:30 +00:00
Ben Johnson 9a15130a4c Persist TSI tombstones. 2018-01-15 12:00:30 +00:00
Ben Johnson 69757ccd15 Fix partition series set building. 2018-01-15 12:00:30 +00:00
Edd Robinson 3d153e3808 Don't creation series in partition if none assigned 2018-01-15 12:00:30 +00:00
Edd Robinson 4913f2b4ac Refactor test Index/Series file with correct open 2018-01-15 12:00:30 +00:00
Edd Robinson 96d55c4471 Fix reference bug 2018-01-15 12:00:30 +00:00
Edd Robinson bb6bfad5ea Ensure inmem index updated properly 2018-01-15 12:00:30 +00:00
Edd Robinson b9d0a39131 Skip empty series keys 2018-01-15 12:00:30 +00:00
Edd Robinson 7f244cb29f Use models series key for partition allocation
There are two series key formats: the `models` package format, which is
also line-protocol format, and the `tsdb` package format, which is used
by the series file when serialising series keys.

When writing to a series, rather than taking a `models` format key from
the `coordinator` package and then converting it to a `tsdb` package
format, it would be cheaper to keep the key in the `models` format
before hashing it to determine which partition the key lives in.
2018-01-15 12:00:30 +00:00
Edd Robinson a4bef3a4bc Refactoring delete tests 2018-01-15 12:00:30 +00:00
Edd Robinson 74481b9415 Fix shard tests 2018-01-15 12:00:30 +00:00
Edd Robinson b0e6aeb64c Add some series file testing 2018-01-15 12:00:30 +00:00
Jason Wilder ba9a5af7eb Mark series deleted in series file
This commit adds the ability to correctly mark a series as deleted in
the global series file. Whenever a shard engine determines that a series
should be deleted, it checks with each shard's bitset for series that
are to be deleted and are no longer contained in any shard-local
bitsets.

These series are then removed from the series file.
2018-01-15 12:00:30 +00:00
Edd Robinson 286c8f4c09 Return to original DELETE/DROP SERIES semantics
This reverts commit 59afd8cc90.
2018-01-15 12:00:30 +00:00
Jason Wilder 874d5839da Don't return error for non-existent series file
When dropping series, if the series file does not exists we returned
and error.  This breaks compatibility with prior versions that would
not return an error if the series do not exists.
2018-01-14 12:53:26 -07:00
Jason Wilder 5d1f76192a Ensure series file is not closed while in use 2018-01-12 16:58:33 -07:00
Jason Wilder 72910b6bf0 Don't clear partitions on close
Since partitions slice is not protected under a lock, setting it to
nil while closing causes a race if concurrent calls are accessing
the partitions slice elsewhere.  Since partitions do handle
concurrency and Open resets the slice, just leave it as it after
closing.
2018-01-11 15:46:38 -07:00
Jason Wilder a4d13c7098 Update TestIndex_SeriesIDSet
The series ids are no longer lower than 4 so this test will always
fail.
2018-01-11 13:49:50 -07:00
Jason Wilder c2cbd14e09 Fix TestEngine_DisableEnableCompactions_Concurrent hang
This test could hang due to an existing race that is still not fixed.
The snapshot and level compaction goroutines woule end up waiting on
the wrong channel to be closed so whey would never exit.
2018-01-11 11:58:20 -07:00
Ben Johnson d610a79487
Merge pull request #9295 from influxdata/partition-series-file
Partition series file
2018-01-11 08:45:18 -07:00
Edd Robinson ecef790574 Update timeout on test 2018-01-11 11:41:30 +00:00
Edd Robinson ed8b9925c8 Comment update 2018-01-11 01:01:54 +00:00
Edd Robinson e2262d3e8e Implement series id tracking in TSI index 2018-01-11 01:01:54 +00:00
Edd Robinson e610e7c21d Track undeleted series IDs per-shard with inmem
This commit adds a bitset into each shard's in-memory index, to be used to
track undeleted series ids. Currently tsi1 support is not implemented.

When new series are added to the shard, the series id is added
to the bitset. When series are deleted from the shard, the series
ids are removed from the bitset.

Becasue each shard shares the same inmem index reference, the bitset
is stored in the `ShardIndex`, which is local to each shard, and then
different references are passed into the shared `Index` object, depending
on which shard is writing the series.
2018-01-11 01:01:54 +00:00
Edd Robinson e6f3aa107a Move SeriesSet to tsdb.SeriesIDSet 2018-01-11 01:01:54 +00:00
Edd Robinson 35543e385f Tidy up 2018-01-11 01:01:54 +00:00
Ben Johnson 9bf45fcae0
Improve inmem insert performance with non-sequential series ids. 2018-01-10 13:08:16 -07:00
Adam 938db68198
Update restore functionality to run in online mode, consume Enterprise backup files. (#9207)
* Live Restore + Enterprise data format compatability

* Extended ImportData to import all DB's if no db name given

* Added a new enterprise data test, and backup command now prints the backup file paths at conclusion

* Added whole-system backup test

* Update to use protobuf in all enterprise data cases

* Update to test to do cross-testing with enterprise version

* incremental enterprise backup format support
2018-01-10 13:59:18 -05:00
Edd Robinson a4d48f95f3
Merge pull request #9303 from influxdata/er-store-race
Fix race in DeleteDatabase
2018-01-10 17:57:46 +00:00
Ben Johnson ac4dc91c64
Partition series file. 2018-01-10 08:33:25 -07:00
Jason Wilder 92f86b1b8f Fix large memory spikes in cache
The cache defaulted to entry capacity size of 32.  This default
is fine for lower cardinalities, but causes big spikes in InUse
heap with higher cardinalities that can OOM the process.  Since
the hints had to be removed previously due to increased memory usage,
they are now completely removed.  For lower cardinalities, we do
grow the slice, but this has a small performance penalty compared
to the large memory usage/OOMs with larger cardinalities.
2018-01-10 07:56:46 -07:00
Edd Robinson 6eeecb477e Fix race in DeleteDatabase 2018-01-10 14:33:14 +00:00
Ben Johnson 3108eea330
Merge pull request #9291 from influxdata/bj-fix-series-file-delete
Fix series file removal after DROP DATABASE.
2018-01-08 13:20:02 -07:00
Ben Johnson fe2116a4fc
Fix series file removal after DROP DATABASE. 2018-01-08 11:40:06 -07:00
David Norton 1ea41b0dd6
Merge pull request #9287 from influxdata/dn-return-digest-size
fix #9286: return digest size
2018-01-08 13:30:56 -05:00
David Norton 1c452d83cb fix #9286: return digest size 2018-01-08 13:15:14 -05:00
Ben Johnson c0a46d2d3d
Fix series file compaction stall.
The series file compaction previously did not snapshot the max
offset before compacting and would keep compacting until it reached
the end of segment file. This caused more entries than expected into
the RHH map and this map gets exponentially slower as it gets close
to full.
2018-01-08 09:53:01 -07:00
Ben Johnson 88ce43a639
Merge pull request #9285 from influxdata/bj-series-file-windows
WIP: Close series file on database deletion.
2018-01-08 09:51:58 -07:00
Ben Johnson 6f32f15fd3
Add closed series file checks. 2018-01-08 09:11:29 -07:00
Ben Johnson 370d363d38
Close series file on database deletion. 2018-01-05 13:33:35 -07:00
Edd Robinson 86c443cb02 Change series dir location 2018-01-05 16:40:23 +00:00
Edd Robinson 83d0ec8359 Optimise TagKeys and fix duplication bug 2018-01-05 12:51:21 +00:00
Ben Johnson 6b4a21cdb2
Merge pull request #9282 from benbjohnson/fix-series-segment-replay
Fix series segment replay.
2018-01-04 18:32:53 -07:00
Ben Johnson eab6333c27
Fix SeriesSegment replay. 2018-01-04 18:28:02 -07:00
Jason Wilder b647c9d29b
Merge pull request #9278 from hpbieker/hpb-compacting-sorting-2
Fixed issue where compacting did not sort when blocks are unsorted and overlapping
2018-01-04 13:21:18 -07:00
Hans P. Bieker a85306c53e Updated mergeUnsigned by running "go generate ./tsdb/engine/tsm1". 2018-01-04 19:35:01 +01:00
Edd Robinson f73a710320 More insight into assertion 2018-01-04 16:23:50 +00:00
Edd Robinson c13910a51f Don't try to load .series directory 2018-01-04 16:23:50 +00:00
Ben Johnson 28e6a1a7c2
Fix series file key/id map compaction. 2018-01-04 09:16:29 -07:00
Hans Petter Bieker 7a273ccdb5 Fixed issue where compacting did not sort when block are unsorted and overlapping. 2018-01-04 15:25:26 +01:00
Jason Wilder bf66f20388
Merge pull request #9267 from hpbieker/hpb-compacting-sorting
Sort blocks by time when compacting
2018-01-03 17:43:38 -07:00
Ben Johnson 3ac428920c
Merge pull request #9276 from benbjohnson/fix-series-index-compaction
Fix series index compaction.
2018-01-03 15:13:19 -07:00
Ben Johnson 48648e828d
Fix series index compaction. 2018-01-03 12:47:07 -07:00
Ben Johnson 31c50532db
Add series existence check in tsi1. 2018-01-03 12:20:35 -07:00
Ben Johnson 98486a284a
Merge pull request #9265 from benbjohnson/series-file-compaction
Sequential series file id & series file segmentation
2018-01-03 10:05:59 -07:00
Ben Johnson 3900c948a2
Fix requested changes. 2018-01-03 10:04:12 -07:00
Edd Robinson f9ea54198f rename series directory 2018-01-03 15:44:58 +00:00
hpbieker c892bf15a1 Fix missing sorting of blocks when compacting. 2018-01-03 10:21:11 +01:00
hpbieker ee185e18b7 Added unit test TestCompactor_Compact_UnsortedBlocks. 2018-01-03 09:42:36 +01:00
Ben Johnson 52630e69d7
Integrate SeriesFileCompactor 2018-01-02 12:20:03 -07:00
Ben Johnson 56980b0d24
Segment series file 2017-12-29 11:57:45 -07:00
Ben Johnson 4ab1542cfc
Series file compactor. 2017-12-29 11:57:45 -07:00
Stuart Carnie ed207b54c3 updates after TSI / series file merge 2017-12-29 10:58:25 -07:00
Stuart Carnie 638caf3b58 ensure correctly aligned for 32-bit architecture 2017-12-29 07:58:52 -07:00
Stuart Carnie 455013a486 updates per PR review comments 2017-12-29 07:58:52 -07:00
Stuart Carnie 98aa368b7f prefer NameBytes 2017-12-29 07:58:52 -07:00
Stuart Carnie 5dfe3b2645 inmem startup improvments
* only call ParseTags when necessary
* remove dependency on inmem.Series in tsdb test package
* Measurement and Series are no longer exported. Their use is restricted
  to the inmem package
* improve Measurement and Series types by exporting immutable
  fields and removing unnecessary APIs and locks

Reduced startup time from 28s to 17s. Overall improvement including
#9162 reduces startup from 46s to 17s for 1MM series across 14 shards.
2017-12-29 07:58:52 -07:00
Stuart Carnie ba17264ddd fixes after merge 2017-12-27 17:29:32 -07:00
Stuart Carnie c986cac76e improve performance when writes exceed max tag values or series
```
 benchmark                                                                  old ns/op     new ns/op     delta
 BenchmarkShardIndex_CreateSeriesListIfNotExists_MaxValuesExceeded-8        6175374       2714158       -56.05%
 BenchmarkShardIndex_CreateSeriesListIfNotExists_MaxValuesNotExceeded-8     344502        326312        -5.28%
 BenchmarkShardIndex_CreateSeriesListIfNotExists_NoMaxValues-8              346734        329961        -4.84%
 BenchmarkShardIndex_CreateSeriesListIfNotExists_MaxSeriesExceeded-8        2414945       1996223       -17.34%

 benchmark                                                                  old allocs     new allocs     delta
 BenchmarkShardIndex_CreateSeriesListIfNotExists_MaxValuesExceeded-8        45377          128            -99.72%
 BenchmarkShardIndex_CreateSeriesListIfNotExists_MaxValuesNotExceeded-8     33             20             -39.39%
 BenchmarkShardIndex_CreateSeriesListIfNotExists_NoMaxValues-8              33             20             -39.39%
 BenchmarkShardIndex_CreateSeriesListIfNotExists_MaxSeriesExceeded-8        15219          71             -99.53%

 benchmark                                                                  old bytes     new bytes     delta
 BenchmarkShardIndex_CreateSeriesListIfNotExists_MaxValuesExceeded-8        1354539       480114        -64.56%
 BenchmarkShardIndex_CreateSeriesListIfNotExists_MaxValuesNotExceeded-8     2101          1261          -39.98%
 BenchmarkShardIndex_CreateSeriesListIfNotExists_NoMaxValues-8              2100          1261          -39.95%
 BenchmarkShardIndex_CreateSeriesListIfNotExists_MaxSeriesExceeded-8        707247        477737        -32.45%
 ```
2017-12-27 17:27:03 -07:00
Ben Johnson f240a930c7
Preserve original mmap in series file. 2017-12-21 20:00:05 -07:00
Ben Johnson 895ca7a04b
Adjust 386 max series file size. 2017-12-21 14:50:07 -07:00
Ben Johnson 4fd48cfcd1
Replace in-memory series file map with rhh. 2017-12-21 12:57:21 -07:00
Ben Johnson 4d7426ebbd
Fix race bug. 2017-12-21 10:12:21 -07:00
Ben Johnson 679335d027
Measurement iterator fix. 2017-12-20 15:43:17 -07:00
Ben Johnson 553c092484
Merge branch 'er-tsi-index-part' of https://github.com/influxdata/influxdb into er-tsi-index-part 2017-12-20 15:22:24 -07:00
Ben Johnson d8b1d208c0
rebase 2017-12-20 15:13:34 -07:00
Edd Robinson 9767660b8f Use MeasurementIterator 2017-12-19 19:23:01 +00:00
Ben Johnson 8b2dbf4d83
Merge branch 'er-tsi-index-part' of https://github.com/influxdata/influxdb into er-tsi-index-part 2017-12-19 10:33:02 -07:00
Ben Johnson 107291c6b0
series file refactor 2017-12-19 10:31:33 -07:00
Edd Robinson 72c0ec89fd Fix race on in-memory index 2017-12-18 16:22:19 +00:00
Edd Robinson bde66f19bc Adjust series file size and partitions 2017-12-18 13:17:42 +00:00
Edd Robinson 38af43d5eb Fix engine test races 2017-12-15 23:19:18 +00:00
Edd Robinson 42ba4831ba Update Digest test 2017-12-15 18:45:20 +00:00
Edd Robinson c476a0b4a1 Merge branch 'master' into er-tsi-index-part 2017-12-15 18:31:24 +00:00
Edd Robinson 73fcf894b6 Fix shard races when accessing index 2017-12-15 18:19:55 +00:00
Edd Robinson d59f79338b Update series map threshold 2017-12-15 15:58:01 +00:00
Edd Robinson 3bfe525705 Add 32-bit support to series file
This commit ensures that the series file should work appropriately on
32-bit architecturs. It does this by reducing the maximum size of a
series file to 512MB on 32-bit systems, which should be fully
addressable.

It further updates tests so that the series file size can be reduced
further when running many tests in parallel on 32-bit architectures.
2017-12-15 15:47:26 +00:00
Jason Wilder 2d85ff1d09 Adjust compaction planning
Increase level 1 min criteria, fix only fast compactions getting run,
and fix very large generations getting included in optimize plans.
2017-12-14 22:41:34 -07:00
Jason Wilder 749c9d2483 Rate limit disk IO when writing TSM files
This limits the disk IO for writing TSM files during compactions
and snapshots.  This helps reduce the spiky IO patterns on SSDs and
when compactions run very quickly.
2017-12-14 22:02:32 -07:00