Commit Graph

306 Commits (c665c749fe0aeb858ca2f059991826c923348949)

Author SHA1 Message Date
Jason Wilder 78201e19d0 Refactor DeleteDatabase to use filter/walk funcs 2016-07-14 17:31:34 -06:00
Jason Wilder e0122efcf8 Speed up drop retention policy
Reduce the lock contention on tsdb.Store by taking a short lived
read-lock instead of a long write lock.  Also close shards in parallel
and drop the whole RP dir in bulk instead of each shard dir.
2016-07-14 17:31:34 -06:00
Jason Wilder 6d3d2f6fe9 Speed up drop measurement
Reduces the lock contention on the tsdb.Store by taking a short
read lock instead of a long write lock.  Also processes shards
in parallel instead of serially.
2016-07-14 17:31:29 -06:00
Jonathan A. Sternberg 837a9804cf Refactoring the monitor service to avoid expvar
Truncate the time interval output of the monitor service to be on even
time intervals rather than on every minute based on the start time. This
normalizes the output from the monitor service.
2016-07-07 11:13:58 -05:00
kun 77ed719bc1 delete redundant code in NewStore function 2016-06-24 17:14:00 +08:00
Jonathan A. Sternberg 497db2a6d3 Removing dead code from every package except influxql
The tsdb package had a substantial amount of dead code related to the
old query engine still in there. It is no longer used, so it was removed
since it was left unmaintained. There is likely still more code that is
the same, but wasn't found as part of this code cleanup.

influxql has dead code show up because of the code generation so it is
not included in this pruning.
2016-06-20 22:41:07 -05:00
Ben Johnson 7d4bea7153
add node id to execution options
This commit changes the `ExecutionOptions` and `SelectOptions` to
allow a `NodeID` for specifying an exact node to query against.
2016-06-10 09:20:44 -06:00
Jason Wilder a74ea4cbf4 Allow creating shards in a disable state
For restoring a shard, we need to be able to have the shard open,
but disabled.  It was racy to open it and then disable it separately
since writes/queries could occur in between that time.
2016-06-01 16:17:18 -06:00
Jason Wilder 1ff8ecf4fb Add ability to disable shards
Disabling a shard causes all writes and queries to a shard to return
an error.  This also disables compactions for the shard.
2016-05-31 10:51:54 -06:00
Jason Wilder 209dd005c5 Merge pull request #6627 from influxdata/jw-deadlock
Fix possible deadlock when queries and delete series run concurrently
2016-05-18 15:30:37 -06:00
Joe LeGasse af432e7d12 Fix loop variable reuse in database close
Fixes #6650
2016-05-17 11:25:39 -04:00
Jason Wilder 57d4becaec Fix possible deadlock when queries and delete series run concurrently
This locks showeed up in a deadlock systems running queries and
delete series across a large dataset.  Queries should not need to
lock the tsdb.Store for writes
2016-05-13 17:04:12 -06:00
Jason Wilder 5b6f3afefa Limit concurrent shards loading to number of cores available 2016-05-13 15:41:32 -06:00
Jason Wilder 9e54adc719 Speed up drop database
Drop database was closing and deleting each shard dir individually and
serially.  It would then delete the empty database dirs.

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

This also reworked the locking to avoid locking the tsdb.Store for
long periods of time.  That can cause queries and writes for other
databases to block as well.
2016-05-13 10:26:28 -06:00
Cory LaNou f415cf89ad wip 2016-05-10 11:01:03 -05:00
Cory LaNou a3bf3e2ef1 added baseline backup/restore plumbing 2016-05-10 08:14:51 -05:00
Jason Wilder 61e0d8ff93 Fix log prefix formatting 2016-05-02 11:36:04 -06:00
Jason Wilder abcb559b09 Remove index meta data when series and measurements are gone
This remove the dropMeta param from the tsdb.Store.DeleteSeries and
lets the shard determine when to remove the meta data from the index
based on what series still have data in the shard.

This uncovered a nasty bug in compactions where a fully deleted series would
prematurely end the compactions and not carry forward the rest of the data
in the TSM file.  This is now fixed as well.
2016-04-29 16:31:57 -06:00
Ben Johnson f7af787aef
add DELETE query support
This commit adds query language support for deleting series with a
`DELETE` query.
2016-04-27 15:16:23 -06:00
Stephen Gutekanst 9dc09c5257 Make logging output location more programmatically configurable (#6213)
This has various benefits:

- Users embedding InfluxDB within other Go programs can specify a different logger / prefix easily.
- More consistent with code used elsewhere in InfluxDB (e.g. services, other `run.Server.*` fields, etc).
- This is also more efficient, because it means `executeQuery` no longer allocates a single `*log.Logger` each time it is called.
2016-04-20 21:07:08 +01:00
joelegasse 84f8dd7c85 Merge pull request #6190 from influxdata/jw-race
Fix race on measurementFields
2016-04-06 08:13:58 -04:00
Jonathan A. Sternberg 37b63cedec Cleanup QueryExecutor and split statement execution code
The QueryExecutor had a lot of dead code made obsolete by the query
engine refactor that has now been removed. The TSDBStore interface has
also been cleaned up so we can have multiple implementations of this
(such as a local and remote version).

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

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

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

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

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

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

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

Fixes #6188
2016-04-01 18:57:01 -06:00
Jason Wilder 96e076b6df Limit how many shards are loaded concurrently
Since loading a shard can allocate a lot of memory, running them all
at once could OOM the process.  This limits the number of shards
loaded to 4.  This will be changed to a config option provided the
approach helps.
2016-03-29 12:59:26 -06:00
Jason Wilder 03ced4cc90 Load shards concurrently 2016-03-29 12:58:52 -06:00
Ben Johnson beda072426 add support for remote expansion of regex
This commit moves the `tsdb.Store.ExpandSources()` function onto
the `influxql.IteratorCreator` and provides support for issuing
source expansion across a cluster.
2016-03-11 12:40:07 -07:00
Jason Wilder c44195d999 Convert measurementToRegex to exported func
Make it consistent with other conventions where exported funcs
take a lock.
2016-03-09 17:45:37 -07:00
Jason Wilder 992c78ee22 Remove period shard maintenance goroutine
This is no longer used in tsm and just peridocially locks everything
for no reason now.
2016-03-09 17:31:02 -07:00
Jason Wilder ae2360df7c Use read lock to expand sources
A write-lock was taken which locks the whole store during a query
that needs to expand sources.  Under load, writes can start to fail.
2016-03-09 17:22:57 -07:00
Edd Robinson 7dbc0f49d3 Merge pull request #5818 from influxdata/er-upgrade-error
Highlight upgrade info for old shards
2016-03-09 19:39:59 +00:00
Ben Johnson 41dde61226 SHOW SERIES 2016-03-08 11:47:57 -07:00
Mark Rushakoff cdcb079769 Tag TSM stats with database, retention policy
... by extracting the db/rp from the given path.

Now that the code has "standardized" on extracting db/rp this way, the
ShardLocation struct is no longer necessary and thus has been removed.
We're back on the previous style of passing the path and walPath to
NewShard.
2016-02-29 09:17:34 -08:00
Mark Rushakoff 40a98e0d55 Add database, RP as tags on shard stats
This commit updates tsdb.Shard to contain a ShardConfig and updates
tsdb.Store to directly reference a map of tsdb.Shard rather than the
previous tsdb.shardLocation abstraction.
2016-02-25 13:41:55 -08:00
Mark Rushakoff e7bb855ab2 Merge pull request #5816 from influxdata/mr-database-stats
Track stats for number of series, measurements
2016-02-25 08:13:04 -08:00
Ben Johnson 0dda9f6608 add remote execution
This commit adds remote execution to the query engine.
2016-02-25 08:41:20 -07:00
Mark Rushakoff fb83374389 Track stats for number of series, measurements
Per database: track number of series and measurements
Per measurement: track number of series
2016-02-24 08:10:16 -08:00
Edd Robinson 16995b6c23 Add ShardError to provide context about shard that errored 2016-02-24 13:33:07 +00:00
Edd Robinson 99a7341701 Wire up DROP retention policy to TSDB store.
Fixes #5653 and #5394.

Previously dropping retention policies did not propogate to local TSDB
shards. Instead, the retention policiess would just be removed from the
Meta Store.

This PR adds ensures that data associated with retention policies is
removed, when the retention policy is dropped.

Also, it cleans up a couple of other methods in `tsdb`, including the
requirement to provide (redundant) shardIDs when deleting databases.
2016-02-19 11:15:00 +00:00
Ben Johnson e3b4b71c13 refactor query executor
This commit moves the `QueryExecutor` to the `cluster` package
and provides an interface to it inside the `influxql` package.
2016-02-17 15:13:56 -07:00
Mark Rushakoff fc9ab7a46f Miscellaneous cleanup in tsdb package
* When possible, initialize maps/slices to exact length/capacity
  * See slice benchmarks at
    https://gist.github.com/mark-rushakoff/b5650bd8f06bece0b9fd
* Fixed some typos
* Removed an unnecessary loop in stringset.intersect
2016-02-10 18:00:47 -08:00
Justin Nuß 82c276756a Lint tsdb and tsdb/engine package 2016-02-10 21:33:46 +01:00
Ben Johnson d9a6a7340f add canonical paths 2016-02-10 11:30:52 -07:00
Ben Johnson 5a0d1ab7c1 rename influxdb/influxdb to influxdata/influxdb
This commit changes all the import and URL references from:

    github.com/influxdb/influxdb

to:

    github.com/influxdata/influxdb
2016-02-10 10:26:18 -07:00
Ben Johnson 32be4c250f fix non-existent shard handling
This commit removes `nil` shards returned from `tsdb.Store.Shards()`
which caused panics in some SELECTs. This can occur if the meta
store has created shards before the store or if the shards are
distributed throughout a cluster.

Fixes #5555
2016-02-10 09:40:29 -07:00
Ben Johnson 627cd9d486 add dedupe iterator 2016-02-10 09:40:29 -07:00
Ben Johnson 2bdc9404ef revert meta execution 2016-02-10 09:40:28 -07:00
Ben Johnson cde973f409 refactor query engine 2016-02-10 09:40:24 -07:00
Paul Dix 9cede5fb71 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
David Norton 3014fb90e4 fix #4303: don't drop from multiple databases 2015-12-12 13:54:23 -05:00
Jason Wilder 9046244df3 Remove the shard references when database is dropped
The shards map still held a reference to a shard that was dropped
which caused the periodic mainteance task to report errors continuously.
2015-10-26 13:04:57 -06:00
Philip O'Toole 6d38559f24 RLock access to store's shards
Fix issue #4442.
2015-10-13 20:28:19 -07:00
Jason Wilder 41e3294d4a Fix panic: assignment to entry in nil map
Closing the store did not properly return an error for in-flight
writes because the closing channel was set to nil when closed.  A
nil channel is not selectable so writes continue on past the guard
checks and trigger panics.
2015-10-06 14:03:52 -06:00
Jason Wilder ab791ba913 Fix TestStoreOpenShardCreateDelete
Shard path can be a directory.
2015-10-05 20:09:56 -04:00
Paul Dix 0b33a71bb7 Add recover to maintenance. Change snapshot writer to not use bolt on shard. 2015-10-05 20:06:22 -04:00
Paul Dix 1c8eac1523 Add PerformMaintenance to store for flushes and compactions.
Also fixed shard to work again with b1 and bz1 engines.
2015-10-05 20:06:22 -04:00
Ben Johnson 8e27cf1fd8 Merge remote-tracking branch 'upstream/master' into refactor-select-mapper
Conflicts:
	tsdb/store.go
2015-09-22 13:58:24 -06:00
Ben Johnson 1b8b625787 refactor SelectMapper 2015-09-22 13:09:26 -06:00
David Norton 8bd2408320 convert SHOW TAG KEYS to distributed query 2015-09-21 11:30:51 -04:00
Cory LaNou d19a510ad2 refactor Points and Rows to dedicated packages 2015-09-16 15:33:08 -05:00
Philip O'Toole 255fb3364d Don't close nil channel
Obviously a TSDB store may be closed before it's opened.
2015-09-08 10:49:45 -07:00
Jason Wilder 6b2b29625d Ensure the tsdb.Store is not closed before creating a shard
Fixes panic: assignment to entry in nil map

Fixes #3848
2015-09-08 11:04:00 -06:00
Jason Wilder 6b4926257a Add inspect tool
Start of a lower-level file inspection tool.  This currently dumps
summary statistics for the shards, index and WAL that can be used to
understand the shape of the data is in the local shards.  This util
operates on the shards itself and not through the server and is intended
more for debugging/troubleshooting.
2015-09-04 10:38:59 -06:00
Jason Wilder f72fd247b5 Fix panic when querying against non-fully replicated shards
The TSDBStore was returning a nil mapper if the shard did not exist.  The caller always
assumed the mapper would not be nil causing a panic.  Instead, have the mapper skip the mapping
phase if it's shard reference is nil.  This fixes queries against data-only nodes and against
shards that are not fully replicated in the cluster.

Fixes #3574
2015-08-31 10:03:07 -06:00
David Norton 88f556af72 convert SHOW MEASUREMENTS to a distributed query 2015-08-23 23:09:51 -04:00
Paul Dix 73f3dc1e14 Update store to properly manage WAL create/delete.
* Update the store to remove the WAL directories associated with a shard or database when they are deleted.
* Fix the Store so that it creates separate WAL directories for databases and retention policies.
2015-08-21 11:22:04 -04:00
Paul Dix 9df3b7d828 Add WAL configuration options 2015-08-18 16:59:54 -04:00
Paul Dix 3348dab4e0 Fix bug with new shards not getting series data persisted. 2015-08-16 15:45:09 -04:00
Jason Wilder 668181d275 Make log statements more consistent
* Capitalize first letter of message
* Log all services staring consistently
* Remove some extraneous log statements in meta.Store
* Log data dirs for meta, data and hinted handoff
2015-08-13 10:01:42 -06:00
Daniel Morsing 65ea56ae2c check error when opening shard DBs.
This should catch the case where someone messed up the permisssions
for a database that they moved from one machine to another.
2015-08-10 09:31:22 -07:00
Ben Johnson cc0607a5cf remove Engine.Flush() 2015-07-22 11:08:10 -06:00
Ben Johnson a7f50ae03c refactor storage to engine 2015-07-22 11:08:10 -06:00
Ben Johnson de1f9a3736 refactor tsdb tests into test package 2015-07-22 11:07:06 -06:00
Philip O'Toole 3695ebcd4e Move to a single LocalMapper type 2015-07-18 16:10:12 -07:00
Philip O'Toole 0d6c6bbe6f Correctly check if raw derivative is required
The multiple checks for Mapper and Executor type -- the lack of DRYness
in this code -- meant the same checks would need to be copied. Therefore
this change, as well as fixing the bug, improves the situation a little
bit by *asking* the Mappers what type of Executor is required. This code
is still not ideal.

Fixes #3355.
2015-07-16 23:28:38 -07:00
Philip O'Toole d8c31f0b3c Merge pull request #3320 from influxdb/streaming_dq
Support Distributed Queries
2015-07-16 12:33:21 -07:00
Philip O'Toole 74cb96646c Refactor query engine for distributed query support
With this change, the query engine code gathers information about
shards and tagsets by working with individual shards, collating the
information, and returning that to the client. It does not assume that any
particular shard is local, and accesses all shards through abstracted
Mappers, of which there are two types -- a Mapper type for Raw queries
and a second type for Aggregate queries. There are corresponding
Executors for each type of Mapper, but both types of Executors share the
same interface.
2015-07-15 12:54:55 -07:00
Philip O'Toole 09d7dfbaae Form database path correctly on DROP DATABASE
Fixes #3330
2015-07-15 11:14:49 -07:00
Philip O'Toole 7a87fbc58a Flush WAL as fast as possible on start-up
This addresses complaints of long start-up times when there is lots of
data sitting in the WAL.
2015-07-08 17:14:28 -06:00
Philip O'Toole ca86fa2633 Allow WAL inter-flush time to be configurable 2015-07-02 10:40:26 -04:00
Ben Johnson b574e2f755 Add write ahead log
This commit adds a write ahead log to the shard. Entries are cached
in memory and periodically flushed back into the index. The WAL and
the cache are both partitioned into buckets so that flushing doesn't
stop the world as long.
2015-06-25 15:47:13 -06:00
Philip O'Toole 01700f79b0 On DROP DATABASE remove from TSDB index 2015-06-22 11:44:46 -07:00
Ben Johnson bc31783a00 Refactor backup and restore
This commit updates the snapshot code as well as the "backup" and
"restore" command to work with the new architecture.
2015-06-10 22:07:01 -06:00
Philip O'Toole 6d26f9c8a8 Merge pull request #2856 from influxdb/rv_fixes
Series was not already dropped, return false (and other fixes)
2015-06-10 20:57:46 -07:00
Jason Wilder 67d4ef0e28 Don't queue write failures that due to type conflicts
These will never succeed and will stay in the queue indefinitely.
2015-06-10 14:52:59 -06:00
Philip O'Toole bc68afbe85 Fix minor spelling mistake 2015-06-09 14:35:38 -07:00
Philip O'Toole ca9f231fa1 Merge pull request #2776 from influxdb/enforce_retention_2_phase
Enforce retention policies
2015-06-05 11:15:21 -07:00
Paul Dix 4ba7c5d1c1 Merge pull request #2787 from influxdb/pd-drop-database
Wire up DROP DATABASE query
2015-06-05 20:09:06 +02:00
Paul Dix 70e10b136e Wire up DROP DATABASE query. 2015-06-05 12:31:04 -04:00
Philip O'Toole 81ec7353ce TSDB store can return all known Shard IDs 2015-06-04 17:02:22 -07:00
Paul Dix 55e0de30bd Merge pull request #2773 from influxdb/pd-locking
Ensure proper locking of index structures on writes and queries.
2015-06-04 19:50:49 -04:00
Philip O'Toole 5ea2042356 Add DeleteShard to TSDB store 2015-06-04 12:22:38 -07:00
Paul Dix 408bc3f81e Ensure proper locking of index structures on writes and queries. 2015-06-04 14:50:32 -04:00
Paul Dix 99446786f9 Merge pull request #2752 from influxdb/pd-drop-measurement
Wire up DROP MEASUREMENT
2015-06-03 14:02:37 -04:00
Cory LaNou be91c40b9a fix data race in WriteToShard 2015-06-03 11:46:18 -06:00
Paul Dix 9c4da3002c Wire up DROP MEASUREMENT
* Add deleteMeasurement to store and shard
* Add DropMeasurement to DatabaseIndex
* Update ErrMeasurementNotFound and ErrDatabaseNotFound to not include the first line of the stack trace.
2015-06-03 11:32:50 -04:00
Paul Dix c098c6fd78 Merge pull request #2728 from influxdb/pd-tsdb-drop-queries
Wire up DROP SERIES.
2015-06-02 11:30:49 -04:00
Paul Dix 4a1ce77090 Wire up DROP SERIES.
* Pulled over updates to ast and parser from master
* Updated store and shard to be able to drop series
* Pulled updates to database.go from master into tsdb/meta.go
2015-06-02 11:20:20 -04:00
Ben Johnson c916256ac9 Rename cluster.Writer to cluster.ShardWriter. 2015-05-30 14:05:27 -06:00
Paul Dix 15d37fd388 Make store open every shard on load. Fix shard to set measurementFields on load.
Fixes issue where queries wouldn't be able to hit anything because the index does't load until the shard is open.

Fix an issue where field codecs weren't populated in the shard when loading.
2015-05-30 11:53:53 -04:00
Paul Dix f660b1a3d3 Create QueryExecutor in tsdb. 2015-05-29 14:59:57 -06:00
Paul Dix 072dacc1ab Update tx.go to work with tsdb 2015-05-29 14:59:57 -06:00
Ben Johnson 75ab63b538 Refactor meta statement execution to meta.StatementExecutor. 2015-05-29 14:54:04 -06:00
Jason Wilder 85f59d696b Create and open shards on-demand
Uses a structure like:

  /root/
      /db1/rp1/1
              /2
      /db2/rp2/3

If a write is assigned to a shard on the local node but the shard
has not been created, create it when the write returns an error
and retry the write.
2015-05-26 16:38:45 -06:00
Jason Wilder 7ace10f7e6 Load shards from filesystem when tsdb.Store is opened 2015-05-26 15:43:46 -06:00
Paul Dix 01618dc143 Move data.Node to tsdb.Store. Move data to cluster. 2015-05-26 15:56:54 -04:00