Commit Graph

893 Commits (5a61bdad704d99a2510119029d28c66b1f467471)

Author SHA1 Message Date
Jason Wilder 15d723dc77 Change default engine to tsm1
data engine config var is ignored now and you can only create tsm1
shards.  Exists shards will work as is until they are migrated to
tsm1 shards.
2016-01-11 12:02:36 -07:00
Ben Johnson f5ee6a0713 limit raw query fetch
This commit enforces a limit on `RawMapper` so that it will not
produce more values than are specified by the LIMIT clause.
Previously the mapper would read up to the chunk size and the
values would be limited afterward.
2016-01-11 09:01:49 -07:00
Jason Wilder 24f1bcfd20 Remove Dev prefix from tsm engine/tx 2016-01-10 16:43:36 -07:00
Jason Wilder 5b179113fc Don't close tsm cursor prematurely
We were closing the cursor when we read the last block which caused
the internal state to be cleared.  In a group by query, we seeked multiple
times so depending on the group by interval and how the data was laid out
in the blocks, we woudl close the cursor and the last block would get skipped.

Fixes #5193
2016-01-10 15:26:01 -07:00
Jason Wilder 3c45015311 Remove MAP_POPULATE
This may be causing slow restart times for systems with many large TSM files.
What I believe is happening at startup in these cases is that multiple goroutines
are started to load each TSM file concurrently.  The kernel appears to serialize
mmap calls from the same process so all of the goroutines end up getting blocked
on the actual mmap system call.  MAP_POPULATE instruct the kernel to pre-fault the
page table for the files and triggers read-ahead of the pages.  For larger, 2GB files,
this makes the mmap call more expensive and slower.  When there are many of these files
and calls it is possible to fill all available memory with pagecache.  In this case,
the OS will end up pre-faulting pages from one file and have to remove pages that it just
loaded from another files causing slowness.  MAP_POPULATE may also be cause much more data
to be pre-faulted than necessary.  To load a file, we just need to scan the index at the end
of the file.  MAP_POPULATE is likely causing the whole file to be loaded when it won't actually
be accessed for a while (or at all).

Might fix issue #5311.
2016-01-08 08:45:27 -07:00
Jason Wilder 756421ec4a Look for fully compacted block in addition to max size during compaction
Some data shapes would cause files to grow larger than the max size more
quickly which resulted in them getting skipped by the full compaction planner
at times.  Some datasets that could make this happen are very large keys or
very large numbers of keys (10M).  When this happened, multiple max sized
files would accumulate but the blocks would not be full.  When the shard went
cold for writes, these files would get recompacted down to the optimal size, but
a lot of space would be wasted in the mean time.
2016-01-07 15:18:42 -07:00
Jason Wilder faf8ee17fa Fix typo 2016-01-06 12:53:04 -07:00
Jason Wilder d2b7c03175 Re-use the series key
Avoid allocating the string twice.
2016-01-06 12:52:13 -07:00
Jason Wilder 2f7a0090c1 Don't allocate a pre-sized buffer for each cursor
This is contributing to some of the high memory usage on queries and possibly
some OOMs.  This is slightly slower, but removing it allows some fairly large
count queries over 5M series to complete instead of crashing the process using
tsm1 engine.
2016-01-06 10:50:38 -07:00
Jason Wilder 6f577cfef5 Reduce allocations when compacting
Key() returned the key and the entries.  We did not always need the
entries so they would be allocated and ignored.  Added a KeyAt func
that just returns the key to avoid the unnecesary entries allocation.
2016-01-05 16:16:44 -07:00
Jason Wilder 9a9ccab560 Reduce allocation in wal encoder
Use sync.Pool for some temporary buffers used while encoding instead of
allocatin new ones each time.  Also increased the default buffer size which
might be too small.  Probably need to make this a config var.
2016-01-05 16:12:25 -07:00
Jason Wilder ee54a1e791 Write TSM data directly to writer
We were buffering up the data to write into byte slices to reduce
IO calls but at larger sizes, this causes memory to spike.  The TSMWriter
was switched to use a bufio.Writer internally so this byte slice buffering
is unnecessary and costly now.
2016-01-05 14:46:07 -07:00
Jason Wilder d2889ecd6a Avoid creating slices of all keys during compaction 2016-01-05 09:38:00 -07:00
Jason Wilder 7794b9c5d4 Fix panic: runtime error: slice bounds out of range
The block count was an uint16 when incrementing the index location
which was an int32.  This caused the value the uint16 value to overflow
before the index location was incremented causing the wrong location
to be read on the next iteration of the loop.  This triggers the slice
out of range errors.

Added a test that recreates the panic seen in #5257 and possibly #5202 which
is older code.

Fixes #5257
2016-01-04 11:20:24 -07:00
Paul Dix 49d480cb0c Fix races in backup/restore 2015-12-31 08:42:01 -05:00
Paul Dix 5974d37649 Fix backup test to mock out compaction 2015-12-31 08:15:13 -05:00
Paul Dix 9cede5fb71 Address PR comments 2015-12-30 18:06:51 -05:00
Paul Dix 26e1c6464a Update backup to address PR comments 2015-12-30 18:06:51 -05:00
Paul Dix 59fbd371fc Implement backup/restore for TSM.
This changes backup and restore to work for TSM. It breaks it for b1 and bz1, but since those are getting removed it's ok.

The backup runs against any host that is specified and can backup either the metasstore, a database, specific retention policy, or a specific shard. It can also take incremental backups with the `since` flag, which will only backup TSM files that have been created since that timestamp.

The backup is safe to run online. However, for shards that are still hot for writes, they won't be able to create new TSM files while the backup for that single shard runs. If the backup isn't too large and the write throughput isn't too high this shouldn't be a problem since the writes will just go into the WAL cache.
2015-12-30 18:06:50 -05:00
Jason Wilder b6da176a4b Fix direct index size not calculated 2015-12-23 18:01:11 -07:00
Jason Wilder f9ae8077da Allow compactions to run when files have tombstones 2015-12-23 18:01:11 -07:00
Jason Wilder a38c95ec85 Update compactions to run concurrently
This has a few changes in it (unfortuantely).  The main change is to run compactions
concurrently.  While implementing this, a few query and performance bugs showed up that
are also fixed by this commit.
2015-12-23 18:01:11 -07:00
Jason Wilder 48d4156eac Fix blocks not sorted correctly when chunking 2015-12-23 18:01:11 -07:00
Jason Wilder bb2562b2ab Return CompactionGroups from planning 2015-12-23 18:01:11 -07:00
Jason Wilder d0ec0a15e2 Fix wrong test data setup 2015-12-23 18:01:11 -07:00
Ady 5c888b3673 Merge branch 'master' of https://github.com/influxdb/influxdb into mvadu-patch-4358
Trying to get to latest master from influxdb
2015-12-19 01:45:07 +05:30
Jason Wilder 7e97b0eafd Fix rename temp file on windows 2015-12-18 11:57:37 -07:00
Jason Wilder 611017f4ed Add comments 2015-12-18 10:00:07 -07:00
Jason Wilder 930174bf4d Handle calling WriteBlock with no data gracefully 2015-12-18 09:57:16 -07:00
Jason Wilder 6bc7765b88 Handle calling write with no values to TSMWriter gracefully 2015-12-18 09:52:53 -07:00
Jason Wilder 421a127f11 Add indirectIndex.UnmarshalBinary benchmark 2015-12-17 15:38:51 -07:00
Jason Wilder 8c7e11f4cf Aggressively clean up KeyCursor resources 2015-12-17 12:51:51 -07:00
Jason Wilder fd2a409ea3 Skip decoding blocks that are already full 2015-12-17 12:47:05 -07:00
Jason Wilder 825296ddd8 Add comments 2015-12-16 11:30:06 -07:00
Jason Wilder 88324bf61c Optimize indirectIndex.UnmarshalBinary further 2015-12-16 11:28:13 -07:00
Jason Wilder 70d1f45058 Load TSM files concurrently 2015-12-16 11:28:12 -07:00
Jason Wilder 737871268b Speed up indirectIndex.UnmarshalBinary
Remove a bunch of unnecessary allocations to improve startup times.
2015-12-16 11:16:17 -07:00
Jason Wilder 3893bc60e1 Speed up TSM compactor
Just keep the current block for each iterator in the buffers.
2015-12-16 11:16:17 -07:00
Jason Wilder 00f570441b Convert TSMKeyIterator to return blocks 2015-12-16 11:16:17 -07:00
Jason Wilder 59a57d8f73 Convert CacheKeyIterator to return encoded blocks 2015-12-16 11:16:17 -07:00
Jason Wilder 0623648140 Add chunking support back to TSMKeyIterator
Was removed when MergeIterator was deleted.
2015-12-16 11:16:17 -07:00
Jason Wilder 31b97c3fe0 Add max points per block back for CacheKeyIterator
Was removed when MergeIterator was removeed.
2015-12-16 11:16:16 -07:00
Jason Wilder 45e87cdfe4 Strip checksum when returning block from ReadBytes 2015-12-16 11:16:16 -07:00
Jason Wilder 97435b9124 Return minTime/maxTime from BlockIterator.Read 2015-12-16 11:16:16 -07:00
Jason Wilder ce6de9728e Add test for BlockIterator with multiple blocks for a key 2015-12-16 11:16:16 -07:00
Jason Wilder 4a3037814f Add WriteBlock to TSMWriter 2015-12-16 11:16:16 -07:00
Jason Wilder d99c1f944e Add BlockIterator for reading TSM blocks without decoding 2015-12-16 11:16:16 -07:00
Jason Wilder 928aef04cd Split data_file.go into reader.go and writer.go 2015-12-16 11:16:16 -07:00
Philip O'Toole 47317d73b4 Merge pull request #5131 from influxdb/site-fixes
Default data logging to on
2015-12-16 10:03:25 -08:00
Alexandre Viau ad1044dde9 typo: unkown -> unknown 2015-12-15 18:10:47 -05:00
Philip O'Toole d45048455a Default data logging to on 2015-12-15 13:15:38 -08:00
Philip O'Toole 0e4bc275d8 Merge pull request #5115 from influxdb/site-fixes
Log TSM initialization
2015-12-15 13:13:17 -08:00
Philip O'Toole 01ac0b3f23 Tweak compaction log messages 2015-12-15 10:33:13 -08:00
dgnorton d89e233567 Merge pull request #5100 from influxdb/dgn-fix-4303
fix #4303: don't drop from multiple databases
2015-12-15 07:27:05 -05:00
Philip O'Toole a6cdb5229d Log tsm initialization 2015-12-14 15:50:56 -08:00
David Norton 3014fb90e4 fix #4303: don't drop from multiple databases 2015-12-12 13:54:23 -05:00
Philip O'Toole 75764517f6 Merge pull request #5082 from li-ang/fix_x
Fix wrong value of countCompacting in WAL
2015-12-11 10:07:56 -08:00
Philip O'Toole 03f8cd3956 Add comment explaining magic number 2015-12-10 11:46:40 -08:00
Jason Wilder 631ecc23de Fix growing destination buffer during WAL entry encoding
The test to see if the destination buffer for encoding and decoding a WAL
entry was broken and would cause a panic if there were large batches that
would overflow the buffer size.

Fixes #5075
2015-12-10 11:46:40 -08:00
liang@qiniu.com 34bdffdb00 Fix wrong value of countCompacting in wal 2015-12-10 17:47:20 +08:00
Nathaniel Cook b7000c80dd count with fill(none) will drop 0 valued intervals 2015-12-09 15:20:47 -07:00
Ady 07c0939fe1 Added logic To let the memeory mapped files to renamed by OS. Now a copy
is created in memory with SHARED_DELETE flag, so that OS is free to rename
or delete original file
2015-12-10 01:07:50 +05:30
Philip O'Toole da08304780 Merge pull request #4940 from li-ang/fix_aggregative_query_err
Fix distributed aggregative query error
2015-12-09 11:04:40 -08:00
Jason Wilder 992aea7bd3 Merge pull request #5060 from influxdb/jw-drop-db
Cancel writing TSM files when engine closes
2015-12-08 16:16:07 -07:00
Paul Dix b192136887 Merge pull request #5058 from influxdb/pd-update-compaction-logic
Update TSM compaction logic
2015-12-08 18:14:15 -05:00
Paul Dix 27cc2ea0cc Update compact.Plan 2015-12-08 18:01:31 -05:00
Jason Wilder d7cff651d1 Cancel writing TSM files when engine closes
If the engine is closed while a compaction is going on, the close call
blocks until the goroutine exits.  This could be several minutes because
the control does not return back up to the channel selector while there is
still data to write.
2015-12-08 15:41:53 -07:00
Paul Dix 96445a53a7 Update TSM compaction logic
* Update compaction to look at newest files of the smallest step first
* Update compaction to look at older files in larger steps if newer files don't have enough small steps to compact
* Changed the TestDefaultCompactionPlanner_CombineSequence test to reflect what's possible now. We'd only have multiple files in the same generation if the all files but one were over the max allowable size.
* Clean up the logic on when full compactions are run and when planning can be skipped
2015-12-08 17:33:38 -05:00
Jason Wilder 62cb3a1e9b Merge pull request #5057 from influxdb/jw-5046
Fix leaking TSM files when compacting
2015-12-08 13:11:46 -07:00
Jason Wilder 3543917a74 Avoid allocating strings during search 2015-12-08 13:02:17 -07:00
Jason Wilder 99c313ddae Fix leaking TSM files when compacting
The files being read were not closed after the compaction ran causing
them to leak.

Fixes #5046
2015-12-08 12:55:30 -07:00
Jason Wilder 9d82e24ca0 Fix performance of dropping large number of keys 2015-12-08 10:47:06 -07:00
Jason Wilder f245b44afa Set full compaction duration option on planner
Was set on engine and not planner so it was always 0.
2015-12-08 09:56:36 -07:00
Jason Wilder d32aeb2535 Merge pull request #5031 from influxdb/jw-mintime
Dedupe points at query time if there are overlapping blocks
2015-12-07 21:28:29 -07:00
Jason Wilder 87892d79da Dedupe points at query time if there are overlapping blocks 2015-12-07 21:10:10 -07:00
Fazal Majid bb386219f4 ran go fmt on mmap_solaris.go #4787 2015-12-07 17:41:26 -08:00
Fazal Majid 0f889a77d1 fix tsm1 for Solaris #4787, passes unit tests now 2015-12-07 17:14:26 -08:00
liang@qiniu.com c13f8e9128 Fix wrong results of distributed aggregative query 2015-12-08 07:08:46 +08:00
Jason Wilder 4f30d396ae Merge pull request #5026 from influxdb/jw-mintime
Optimize TSM queries with time filter
2015-12-07 15:49:58 -07:00
Jason Wilder a2583d2be1 Reduce lock contention when planning TSM queries 2015-12-07 15:42:36 -07:00
Jason Wilder 4da20c49e9 Optimize TSM file scanning for time queries
Move the index locations planning to be lazily created after the first
seek when we know what time and direction we're searching for.  This
allows files and blocks to be skip before having to scan the files index.

This improves queries times with time filters wherne there are many TSM
files on disk.
2015-12-07 15:42:36 -07:00
Philip O'Toole 99fa678932 Test and variable rename for aggregate math
Fixes nits from https://github.com/influxdb/influxdb/pull/5013.
2015-12-07 14:18:49 -08:00
Philip O'Toole 5d5afcbe50 Merge pull request #5013 from mengjinglei/fix-math-panic
fix aggregate math query
2015-12-07 14:07:48 -08:00
Nathaniel Cook ae4140d384 Merge pull request #5000 from influxdb/nc-issue#4849
Update Derivative for PositionPoint objects
2015-12-07 13:59:15 -07:00
Paul Dix 93d6afec97 Merge pull request #5019 from influxdb/jw-mintime
Remove min time from TSM blocks
2015-12-07 15:00:12 -05:00
Nathaniel Cook 7ffbbc1072 make fill previous for count() queries work 2015-12-07 12:51:40 -07:00
Nathaniel Cook 06bc25d64b add integration tests for derivative calls and all other valid functions, convert PositionPoint to float64 2015-12-07 12:51:39 -07:00
Paul Dix 8096c6b845 Update TSM, address PR #5011 comments
* Moved TSM file extension to a constant
* Fixed typos
* Changed group.size() back to being a uint64 since it can have multiple files up to 4GB each.
2015-12-07 14:47:17 -05:00
Paul Dix 820b0d31d6 Update TSM to delete from the WAL/cache
* Update cache loader to delete entries from cache
* Add cache.Delete()
* Update delete to look at keys in the Cache in addition to the FileStore
* Update cache compaction to never happen if the cache is empty
2015-12-07 14:35:48 -05:00
Jason Wilder cf341eaa6a Remove MinTime from blocks
MinTime is not in the index for each block so storing it in the block
header is redundant.  The encodings also store it in their header so
we are actually storing it 3 times.

Removing this is an incompatible change with the current tsm1 file format.
2015-12-07 11:26:58 -07:00
Adarsha 5482c6de03 Avoid closing the handle in mmap
Added mmap implementation for Windows. It uses MapViewOfFile similar to Bolt's implementation. MapViewOfFile  returns a pointer and not a byte array. Bolt changed their data structure to support it. 

Instead of changing the implementation of tsm data structure, I used a trick shown in https://groups.google.com/forum/#!topic/golang-nuts/g0nLwQI9www to use SliceHeader to convert the pointer into a slice.

Bolt's implementation also closes the file handle in mmap itself. It was resulting in a timeout, so implemented https://github.com/edsrzf/mmap-go/blob/master/mmap_windows.go logic to keep file handle open until munmap
2015-12-07 23:30:19 +05:30
Paul Dix 440a8a8a1f Change all TSM file sizes to uint32 2015-12-07 10:12:24 -05:00
Paul Dix 937233d988 Update TSM compaction planning logic
* Update Plan to do a full compaction if cold for writes
* Remove MaxFileSize as a config variable from Compactor. Should be a set constant
* Update Plan to keep track of if the last check was fully compacted so we can skip future planning calls
* Update compact min file count to 3 so that compactions run more frequently
2015-12-07 08:26:30 -05:00
mengjinglei 5111676646 fix aggregate math query 2015-12-07 16:55:20 +08:00
Paul Dix 1bee7d1512 Update TSM, remove old version, add config
* remove rolloverTSMFileSize constant that is no longer used
* remove the maxGenerationFileCount since it is no longer a limitation that's necessary with the new compaction scheme. We no longer read WAL segments as part of the compaction so memory is only used as we read in each individual key
* remove minFileCount and switch to a user configurable variable
* remove the mutex from WALSegmentWriter. There's never more than one open in the WAL at one time and it's not exported through any function so the lock on the WAL should be used. This simplified keeping track of the last write time and removed a bunch of unnecessary locks.
* update WALSegmentWriter.Write to take the compressed bytes so that encoding and compression can occur before the call to write (while we don't hold the WAL lock)
* remove a bunch of unnecessary locking in WAL.writeToLog
* Add check for TSM file magic number and vesion
* Remove old tsm, log, and unused cursor code
* Remove references to tsm1dev everywhere except in the inspector
* Clean up config options for compaction and snapshotting
* Remove old TSM configuration options
* Update the config.sample.toml with TSM options
* Update WAL compact to force if it has been cold for writes for a configurable period of time (1h by default)
2015-12-06 18:50:39 -05:00
Philip O'Toole 6e88547a5e Support shutting down engine goroutines
This was causing races in the code, when the cache was being reloaded,
because back-to-back open-and-closing of the engine during testing left
goroutines running. With this change the engine is completely shutdown
when Close() is called on it.
2015-12-06 09:16:38 -08:00
Philip O'Toole 0d0b919144 Integrate CacheLoader with tsm2 engine 2015-12-05 22:13:57 -08:00
Philip O'Toole fe7b3ad134 Add CacheLoader
The CacheLoader loads a given cache from a slice of segment files.
2015-12-05 22:13:57 -08:00
Philip O'Toole 4b5fb8db72 WALSegmentReader counts bytes read without error 2015-12-05 22:13:57 -08:00
Philip O'Toole c67831bc79 Remove double-checking of error when reading WAL 2015-12-05 22:13:57 -08:00