Commit Graph

1393 Commits (409de34abfa95f34d48d62ddd1adc0e5cea9ebc9)

Author SHA1 Message Date
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
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
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 2a8ca9a10e
Revert "Use MADV_WILLNEED when loading TSM files"
This reverts commit ee270e1dd2.
2018-03-21 13:26:45 -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 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 c1e1412dae Don't panic when checking for field 2018-03-12 15:25:20 +00: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
Stuart Carnie e493a3e1db use child logger 2018-02-27 20:27:24 -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
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
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 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
Stuart Carnie 6e47ff8d7f simplify code 2018-02-14 06:55:48 -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
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
Joe LeGasse 21a58235fc
Merge branch 'master' into jl-race 2018-01-29 15:52:18 -05: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 90903fa6ed Remove unused code/cleanup engine package 2018-01-20 13:56:45 +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
Joe LeGasse 425a5e5f17 tsm1: prevent WaitGroup race 2018-01-17 13:08:11 -05: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 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
Joe LeGasse 68e20c4f80 wal: update lastWriteTime behavior 2018-01-16 21:22:24 -05: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 a2ece0a49a Pass series id in via Index API 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
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 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
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 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
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
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
David Norton 1c452d83cb fix #9286: return digest size 2018-01-08 13:15:14 -05:00
Hans P. Bieker a85306c53e Updated mergeUnsigned by running "go generate ./tsdb/engine/tsm1". 2018-01-04 19:35:01 +01: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 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
Stuart Carnie ed207b54c3 updates after TSI / series file merge 2017-12-29 10:58:25 -07:00
Stuart Carnie 455013a486 updates per PR review comments 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
Ben Johnson d8b1d208c0
rebase 2017-12-20 15:13:34 -07: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 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
Edd Robinson 59afd8cc90 Return to original DELETE/DROP SERIES semantics
Since possibly v0.9 DELETE SERIES has had the unwanted side effect of
removing series from the index when the last traces of series data are
removed from TSM. This occurred because the inmem index was rebuilt on
startup, and if there was no TSM data for a series then there could be
not series to add to the index.

This commit returns to the original (documented) DROP/DETETE SERIES
behaviour. As such, when issuing DROP SERIES all instances of matching
series will be removed from both the TSM engine and the index. When
issuing DELETE SERIES only TSM data will be removed.

It is up to the operator to remove series from the index.

NB, this commit does not address how to remove series data from the
series file when a shard rolls over.
2017-12-15 00:02:06 +00:00
Edd Robinson 9e3b17fd09 Ensure deleted series are not returned via iterators 2017-12-14 21:29:35 +00:00
Jason Wilder 7dc5327a0a Adjust snapshot concurrency by latency
This changes the approach to adjusting the amount of concurrency
used for snapshotting to be based on the snapshot latency vs
cardinality.  The cardinality approach could use too much concurrency
and increase the number of level 1 TSM files too quickly which incurs
more disk IO.

The latency model seems to adjust better to different workloads.
2017-12-13 13:17:56 -07:00
David Norton 253ea7cc5e feat #9212: fix file in use bug on Windows 2017-12-13 09:29:07 -05:00
David Norton 98ebad951f feat #9212: move reader/writer tests over 2017-12-13 09:28:34 -05:00
David Norton 4e13248d85 feat #9212: add ability to generate shard digests 2017-12-13 09:28:34 -05:00
Edd Robinson f1bcc97e89 Fix auth tests 2017-12-12 21:25:35 +00:00
Edd Robinson 0844f20dc4 Engine tests 2017-12-12 21:25:35 +00:00
Adam af2918a193
fix file_store path bug that affects windows users (#9219) 2017-12-11 17:31:33 -05:00
Edd Robinson 7d13bf3262 merge master 2017-12-08 17:21:58 +00:00
Edd Robinson f6835632e7 Merge master into branch 2017-12-08 17:11:07 +00:00
Edd Robinson 3318c94a2f Clean up 🛁: 2017-12-08 11:38:53 +00:00
Ben Johnson 0e0e7cfc08
Fix tests. 2017-12-07 09:59:39 -07:00
Adam a0b2195d6b
Pulled in backup-relevant code for review (#9193)
for issue #8879
2017-12-07 11:35:20 -05:00
Jason Wilder 9f2a422039 Use disk based TSM index more selectively
The disk based temp index for writing a TSM file was used for
compactions other than snapshot compactions.  That meant it was
used even for smaller compactiont that would not use much memory.
An unintended side-effect of this is higher disk IO when copying
the index to the final file.

This switches when to use the index based on the estimated size of
the new index that will be written.  This isn't exact, but seems to
work kick in at higher cardinality and larger compactions when it
is necessary to avoid OOMs.
2017-12-06 13:45:43 -07:00
Jason Wilder 0a85ce2b73 Schedule compactions less aggressively
This runs the scheduler every 5s instead of every 1s as well as reduces
the scope of a level 1 plan.
2017-12-06 13:45:43 -07:00
Jason Wilder 9c1d7d00a9 Switch O_SYNC to periodic fsync
O_SYNC was added with writing TSM files to fix an issue where the
final fsync at the end cause the process to stall.  This ends up
increase disk util to much so this change switches to use multiple
fsyncs while writing the TSM file instead of O_SYNC or one large
one at the end.
2017-12-06 09:35:24 -07:00
Ben Johnson 493c1ed0d1
inmem tests passing. 2017-12-05 10:49:58 -07:00
Stuart Carnie fffd123646 update unit test 2017-12-01 12:19:28 -07:00
Stuart Carnie 682705d4a7 ensure tsmWriter#Write returns ErrMaxBlocksExceeded 2017-12-01 10:33:59 -07:00
Jason Wilder 909a2fb6cc Fix deletes removing index for invalid time ranges
If a delete for a time that does not exist was run, we would not
remove the series key from the slice of series to remove from the
index.

This could be triggered by running somethin like "delete from cpu where
time = 0" and if there was no data at time 0, the series would still
be removed from the index.
2017-11-30 15:01:01 -07:00
Jason Wilder b6096414c2 Fix compactions aborting early
If there were many individual deletes to a series that ended up
deleting every value in the block and the tombstone timestamps
were not contigous, it was possible for the TSMKeyIterator to
return false for Next incorrectly.  This causes the compaction to
drop any remaining data in the file.

Normally, if all the data is deleted via tombstones, we remove the
whole key from the TSM index.  In this case, we're not able to determine
that the key is fully deleted until the block is decode and tombstones
are applied.

This changes the TSMKeyIterator to detect this condition and continue
to the next key instead of aborting.
2017-11-30 14:38:09 -07:00
Andrew Hare 761a8f8bec Schedule a full compaction after a successful import 2017-11-29 13:50:38 -07:00
Ben Johnson ca09f18e65
intermediate: tsdb compile 2017-11-29 11:20:18 -07:00
Jason Wilder 8633e38549 Fix removing series from index
The loop to check if a series still exists in a TSM file was wrong
in that it 1) exited early after one iteration and 2) had an off
by one error that causes the wrong series to be marked as existing.

This fixes both of these cases which can cause the index to become
inconsistent with the data store on disk.
2017-11-29 10:45:04 -07:00
Edd Robinson c2f7f0f430
Merge pull request #8491 from influxdata/er-tsi-restore
Add support for TSI shard streaming and shard size
2017-11-29 15:40:52 +00:00
Edd Robinson 81976bca59 Refactor based on new design 2017-11-28 17:54:29 +00:00
Jason Wilder e62f6d7cdf Fix Cache.DeleteRange not deleting all data
This fixes a regression in the Cache introduced in ca40c1ad3c where
not all the values in the cache entry would be removed.  Previously,
calling Exclude did not require the values to be sorted.  The change
in ca40c1ad3c relies on the values being sorted so it was possible for
it to find the wrong indexes in when calling FindRange and leave some
data that should be deleted.

Fixes #9161
2017-11-28 10:39:21 -07:00
Edd Robinson b10249a9b3 Fix rebase 2017-11-28 15:58:35 +00:00
Edd Robinson 041a3837be Ensure index can track fields 2017-11-28 15:57:03 +00:00
Edd Robinson 38e0dd695f Allow concurrent access to Engine Index 2017-11-28 15:57:03 +00:00
Edd Robinson 12a2ff7fac Add support for TSI shard streaming and shard size
This commit firstly ensures that a shard's size on disk is accurately
reported when using the tsi1 index, by including the on-disk size of the
tsi1 index in the calculation.

Secondly, this commit add support for shard streaming/copying when using
the tsi1 index. Prior to this, a tsi1 index would not be correctly
restored when streaming shards.
2017-11-28 15:57:02 +00:00
Jason Wilder 5032a802d6
Merge pull request #9168 from influxdata/jw-delete-sort
Ensure series keys are sorted before searching
2017-11-28 08:51:38 -07:00
Jason Wilder b59858e529 Ensure series keys are sorted before searching
The Cache.ApplyEntryFn iterates keys according to the partitions
and hashed values.  This can cause the deleteKeys slice to contain
unsorted keys when deleting series.  The code uses a binary search
on this slice later on and this can fail to detect that the series
should still exists.  The series is then removed from the index
even though it has data still.

Fixes #9116
2017-11-27 17:06:03 -07:00
Jonathan A. Sternberg a73c3a1965 Fix race condition in the merge iterator close method
If the close happens when next is being called, it can result in a race
condition where the current iterator gets set to nil after the initial
check.

This also fixes the finalizer so it runs the close method in a goroutine
instead of running it by itself. This is because all finalizers run on
the same goroutine so a close that takes a long time can cause a backup
for all finalizers. This also removes the redundant call to
`runtime.SetFinalizer` from the finalizer itself because a finalizer,
when called, has already cleared itself.
2017-11-27 16:55:41 -06:00
Stuart Carnie d361d7a659 rename current key index and key index count fields for clarity 2017-11-27 13:26:59 -07:00
Stuart Carnie e1ec331048 improve startup performance
* replaces coordinating goroutines for single k-way heap merge iterator
* removes contention sending keys across buffered channels

startup time from 46s -> 28s for iterating 1MM keys across 14 shards
2017-11-27 12:44:58 -07:00
Edd Robinson e6b7140d65
Merge pull request #9143 from influxdata/er-show-tag-key-perf
SHOW TAG KEYS with high cardinality and many shards
2017-11-27 15:04:15 +00:00
Stuart Carnie 7cdfd95966 initial opentrace implementation for ifql interface
NOTE: does not include a default tracer until configuration across
projects is standardized
2017-11-22 14:42:26 -07:00
Jason Wilder cacb55fac4 Fix typos 2017-11-22 11:17:34 -07:00
Jason Wilder dd1c030815 Remove limit count param on fields
It's not used anymore.
2017-11-22 11:17:34 -07:00
Jason Wilder c14b0e81b7 Save field types to speed up startup
This persists the field types in a shard to avoid having to scan
all the TSM files at startup.
2017-11-22 11:17:34 -07:00
Jason Wilder c8b24b7939 Remove MANIFEST 2017-11-22 11:17:34 -07:00
Edd Robinson 68dd5e27c8 Improve performance of TagKeys 2017-11-21 17:16:47 +00:00
Jason Wilder 50b6ace75f Fix wait reused while disabling compactions 2017-11-20 14:55:47 -07:00
Edd Robinson 6851db3fc9 Add FGA support to SHOW MEASUREMENTS 2017-11-17 11:06:43 +00:00
Jason Wilder aa99a56bf1
Merge pull request #9129 from influxdata/jw-cursor-deletes
Fix KeyCursor not returning remaing blocks
2017-11-16 16:58:30 -07:00
Jason Wilder 02dbe6dbd3 Fix KeyCursor not return remaing blocks
If the first block that needs to be read was partially deleted such
that the trailing end has no values, it was possible for the query
cursor end early.

This was caused by the KeyCursor.ReadFloatBlock returning no values instead
of checking the remaing blocks.
2017-11-16 15:23:34 -07:00
Stuart Carnie 2c2244b79c remove empty file 2017-11-16 09:02:31 -08:00
Ben Johnson ede3fcf98e
intermediate 2017-11-15 16:09:25 -07:00
Jason Wilder e2cb1d0ff4
Merge pull request #9114 from influxdata/jw-force-full-plan
Add capability to force a full compaction
2017-11-15 10:45:00 -07:00
Jason Wilder ef06773d5b Fix panic: runtime error: slice bounds out of range
A panic could occur if an invalid time range was passed to
Exclude/Include, etc.
2017-11-15 08:18:53 -07:00
Jason Wilder 97e0d496a6 Add capability to force a full compaction
This adds the capability to the engine to force a full compaction
to be scheduled.  When called, it snapshots any data in the cache,
aborts running compactions and prevents level plans from returning
level plans.
2017-11-15 07:14:27 -07:00
Ben Johnson ba4c9e0317
Merge remote-tracking branch 'upstream/master' into er-tsi-index-part 2017-11-14 16:14:13 -07:00
Stuart Carnie 2e04e871c9 fix descending queries
* did not handle cached values correctly
* sort shards by time in either ascending or descending
  order depending on the RPC request ordering to ensure they
  are traversed in the correct order.
2017-11-13 17:14:36 -08:00
Jason Wilder 8b18cc4456 Optimize deletes in tsi
The DropSeries code path ended up creating a MeasurementSeriesIterator
for each dropped series, this was too expensive just to see if a
series exists.

This adds a HasSeries func and fixes and issue where TSI files were
compacted while an iterator was still in use causing a panic.
2017-11-13 12:35:38 -07:00
Jason Wilder c0631c2b95 Fix temp tombstone files leaking 2017-11-13 09:02:10 -07:00
Jason Wilder 13692639cb Fix create/delete series race
This fixes a race where writes and deletes to the same series and
measurements could sometimes leave the index in an inconsistent state.
2017-11-13 09:02:10 -07:00
Jason Wilder 80cd5e63af Optimize DeleteSeriesRange
This removes more allocations and speeds up some critical sections.
2017-11-13 09:02:10 -07:00
Jason Wilder aee395d3bd Make DeleteSeriesRange take SeriesIterator 2017-11-13 09:02:10 -07:00
Jason Wilder f893beb6d8 Use MeasurementSeriesKeysByExprIterator for deletes 2017-11-13 09:02:10 -07:00
Jason Wilder 000768371f Optimized deletes in TSM index
This optimizes how deletes are processed to reduce memory usage
and improve efficiency.
2017-11-13 09:02:08 -07:00
Jason Wilder eebd88f825 Don't write tombstones for keys that do not exist
This filters out keys that do not exist in a TSM file to avoid
writing entries that would end up being ignored when applied.
2017-11-13 08:50:07 -07:00
Jason Wilder 88c48ec78b Rework Engine.DeleteSeriesRange to avoid allocations
This removes the containsSeries func which ends up creating a map
sized to the slice of keys passed in.  This doesn't scale well to
high cardinalities and creates a lot of garbage.
2017-11-13 08:50:07 -07:00
Jason Wilder cb658774bb Reduce allocations when reading tombstone v4 2017-11-13 08:50:07 -07:00
Jason Wilder 1c65bb3bb1 Fix leaked goroutine in FileStore.WalkKeys
If fn returned and error, the goroutines sending keys from TSM files
would get blocked indefinitely and leak.
2017-11-13 08:50:07 -07:00
Jason Wilder b0c7a44eaa Adjust min/max time to work in the engine
The query language min and max times are slighly different than the
values used in the engine.  This allows faster codes to be used when
the whole time range is deleted.
2017-11-13 08:50:07 -07:00
Jason Wilder 2959b8d2eb Make BatchDeleters concurrent 2017-11-13 08:50:07 -07:00
Jason Wilder 5a775c50d9 Add DeleteRangeWith
This is a version of DeleteRange that take a func predicate to determine
whether a series key should be deleted or not.  This avoids the large
slice allocations with higher cardinalities.
2017-11-13 08:50:07 -07:00
Jason Wilder 6b19d2b673 Add BatchDeleters type 2017-11-13 08:48:03 -07:00
Jason Wilder 9ac83601cf Use BatchDeleter in FileStore 2017-11-13 08:48:03 -07:00
Jason Wilder 4ed19348fd Add a BatchDelete capability to TSMReader 2017-11-13 08:48:03 -07:00
Jason Wilder 44e782f173 Store temporary tombstones on disk
This removes the in-memory tombstone buffer when writing tombstones
which eliminates one source of large memory spikes during deletes.
2017-11-13 08:48:03 -07:00
Jason Wilder bd15d37c70 Extract commit func 2017-11-13 08:48:03 -07:00
Jason Wilder 1e56894097 Extract writeTombstone func 2017-11-13 08:48:03 -07:00
Jason Wilder b958c68ce5 Avoid re-reading tombstones when writing new ones
This adds a new v4 tombstone format that extends the v3 format
by allowing multiple batches of tombstones to be written without
having to re-read all the existing tombstones.  This uses gzip
multi stream to append multiple v3 files together to create a v4
format.
2017-11-13 08:48:03 -07:00
Jason Wilder 17bae05370 Allow buffering tombstones before writing to disk 2017-11-13 08:48:03 -07:00
Jonathan A. Sternberg 0b7c56bcd8 Update the zap logger dependency
The previous sha was taken from a revision on a devel branch that I
thought would continue staying in the tree after it was merged. That
revision was rebased away and the API was changed for the logger.

This updates the usage of the logger and adds a simple package for
constructing the base logger.

The 1.0 version of zap changed the format of the default console logger
so this change moves over to this new logger instead of attempting to
retain backwards compatibility with the old format.
2017-11-10 16:27:16 -06:00
Ben Johnson 9ad2b53881
intermediate 2017-11-09 09:18:33 -07:00
Stuart Carnie 7cb25ecbff optimized slice when outside timerange
find position then update both slices **once**
2017-11-03 16:31:01 -07:00
Stuart Carnie 295acd6920 also slice values 2017-11-03 15:50:16 -07:00
Stuart Carnie c1da95442c
Merge pull request #9054 from influxdata/js-update-influxql-path-in-templates
Update the influxql path inside of the template files
2017-11-03 09:44:02 -07:00
Jonathan A. Sternberg 748fc4ae79 Update the influxql path inside of the template files 2017-11-03 10:57:17 -05:00
Andrew Hare ecb3952fa9 Allow human-readable byte sizes in config
Update support in the `toml` package for parsing human-readble byte sizes.
Supported size suffixes are "k" or "K" for kibibytes, "m" or "M" for
mebibytes, and "g" or "G" for gibibytes. If a size suffix isn't specified
then bytes are assumed.

In the config, `cache-max-memory-size` and `cache-snapshot-memory-size` are
now typed as `toml.Size` and support the new syntax.
2017-11-01 11:09:09 -05:00
Stuart Carnie 9a43c14653
Merge pull request #9041 from influxdata/sgc-influxql
influxdata/influxdb/influxql -> influxdata/influxql
2017-10-31 07:31:31 -07:00
Stuart Carnie f3d45ba301 influxdata/influxdb/influxql -> influxdata/influxql 2017-10-30 14:40:26 -07:00
Jason Wilder 48ebc53154 Revert "Fix race in disableLevelCompactions"
This reverts commit 4f8580fbaa.
2017-10-30 14:14:50 -06:00
Stuart Carnie dc04eaa8f3 Amendments based on feedback
* Fprint* functions
* No nakedness
* clarify panic messages
* spacing between case statements
* remove break in favor of return
* remove goto in favor of for { continue }
2017-10-25 13:38:07 -07:00
Stuart Carnie c39f1ad748 Add batch cursor support to tsdb and tsm1
* batch cursors return slices of timestamps and values to reduce call
  overhead. Significantly improved iteration.
* added CreateCursor API to Shard, Engine
* moved build*Cursor to code gen
2017-10-25 13:38:07 -07:00
Stuart Carnie 3e28323a10 Simplified Decode*Block functions
* array has already been sized correctly
* eliminates bounds checking for each element access
* reduces decoding of 30,000,000 points via storage API from
  584ms to 540ms on average
2017-10-25 13:38:07 -07:00
Stuart Carnie b7579340fe return query.ErrQueryInterrupted for read on InterruptCh 2017-10-24 14:10:28 -07:00
Jason Wilder 955829e7c3 Merge pull request #9003 from influxdata/jw-delete-regression
Delete series in batches
2017-10-24 13:54:33 -06:00
Jason Wilder cbbbe8bedb Delete series in batches
This fixes a regression where deleting series keys would happen
one at a time instead of in bulk.
2017-10-24 11:06:21 -06:00
Stuart Carnie 02a05e86ee Add missing template changes for EXPLAIN ANALYZE 2017-10-23 14:46:36 -07:00
Stuart Carnie e9313876ab EXPLAIN ANALYZE
* Introduces EXPLAIN ANALYZE command, which
  produces a detailed tree of operations used to
  execute the query.

introduce context.Context to APIs

metrics package

* create groups of named measurements
* safe for concurrent access

tracing package

EXPLAIN ANALYZE implementation for OSS

Serialize EXPLAIN ANALYZE traces from remote nodes

use context.Background for tests

group with other stdlib packages

additional documentation and remove unused API

use influxdb/pkg/testing/assert

remove testify reference
2017-10-20 08:01:37 -07:00
Jason Wilder 05131f4453 Fix indirectIndex not removing fully deleted series
If multiple tombstones exists for a series that ended up causing the
full data to be deleted, the blocks were not removed from the offsets
in the index.  This causes the TSMReader to report that a key exist
but does not have any data.

During a compaction, every key should have at least one value.  Since
this invariant was broken, the compaction aborted early and ends up
dropping all series keys that are lexigraphically greater than where
the breakage occured.  This would cause data to be dropped during the
compaction.
2017-10-18 18:16:41 -06:00
Jason Wilder 9f102adabe Abort BlockIterator iteration if deletes detected
This fixes a potential bug where the BlockIterator would skip blocks
if the underlying TSMReader had deletes on it concurrently.  This
could possibly occur due to changes in 91eb9de3 that now use the
existing TSMReaders from the FileStore instead of creating new ones
during compaction.
2017-10-18 18:16:37 -06:00
Jason Wilder 4d171f3f40 Fix data deleted outside of time range 2017-10-18 13:39:47 -06:00
Jason Wilder 4f8580fbaa Fix race in disableLevelCompactions
There was a race on the WaitGroup where we could end up calling Add
while another goroutine was still waiting.  The functions were confusing
so they have been simplified a bit since the compactions goroutines
have been reworked a lot already.
2017-10-16 10:50:16 -06:00
Jason Wilder e683502dd6 Merge pull request #8961 from lrita/master
remove duplicated code in cacheKeyIterator.encode()
2017-10-16 10:17:32 -06:00
Jason Wilder bc360ccfd5 Merge pull request #8970 from influxdata/jw-wal-panic
Fix corrupted wal segment panic on 32 bit systems
2017-10-16 10:00:02 -06:00
Jason Wilder fb7135ddc8 Fix corrupted wal segment panic on 32 bit systems 2017-10-16 09:41:20 -06:00
lrita 2f0aa4a420 remove duplicated code in cacheKeyIterator.encode() 2017-10-13 20:39:15 +08:00
Stuart Carnie a0848eac8c remove unnecessary err value
readKey never sets error, so it is always nil
2017-10-12 08:28:53 -07:00
Jason Wilder 1401950b10 Only schedule one compaction per shard at a time
The scheduling logic ended up favoring more backlogged shards
too much and would starved active, less backed up shards.  This
occurred because the scheduling kicks in once a second.  When it
runs, it schedules as many compactions as it can.  A backed up shard
would end up having more compactions to run during the loop an would
generally get to schedule them more frequently.

This now allows each shard to try and schedule one compaction at a time
which provides a more balanced approach.  At some point, we'll probably
want to more directly balanc the each shards backlog vs letting it happen
somewhat randomly.
2017-10-09 11:40:32 -06:00
Jason Wilder 00a403f60e Reduce allocation in tsmKeyIterator.Next
This reuses some intermediate buffers and structs while compacting
files.
2017-10-04 17:35:56 -06:00
Jason Wilder 6b6ccf1a40 Wait for compaction gorotuines to finish 2017-10-04 10:01:44 -06:00
Jason Wilder 06226d6fd3 Handle orphan lower level TSM files during full planning
Some files seem to get orphan behind higher levels.  This causes
the compactions to get blocked as the lowere level files will not
get picked up by their lower level planners.  This allows the full
plan to identify them and pull them into their plans.
2017-10-04 08:13:14 -06:00
Jason Wilder a1d0b52897 Allow lower priority compactions to use excess capacity
If there is a backlog of level 3 and 4 compacitons, but few level 1
and 2 compactions, allow them to use some excess capacity.
2017-10-04 08:11:44 -06:00
Jason Wilder f2a681c4cf Unconditionally remove file when calling Remove 2017-10-03 10:49:17 -06:00